mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-07 14:46:44 +00:00
Replace queue by stack in GetRedeemer (#1802)
This commit is contained in:
parent
60e7a8ebed
commit
c731d74bc0
@ -146,17 +146,18 @@ func (tp *transactionsPool) getParentTransactionsInPool(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tp *transactionsPool) getRedeemers(transaction *model.MempoolTransaction) []*model.MempoolTransaction {
|
func (tp *transactionsPool) getRedeemers(transaction *model.MempoolTransaction) []*model.MempoolTransaction {
|
||||||
queue := []*model.MempoolTransaction{transaction}
|
stack := []*model.MempoolTransaction{transaction}
|
||||||
redeemers := []*model.MempoolTransaction{}
|
redeemers := []*model.MempoolTransaction{}
|
||||||
for len(queue) > 0 {
|
for len(stack) > 0 {
|
||||||
var current *model.MempoolTransaction
|
var current *model.MempoolTransaction
|
||||||
current, queue = queue[0], queue[1:]
|
last := len(stack) - 1
|
||||||
|
current, stack = stack[last], stack[:last]
|
||||||
|
|
||||||
outpoint := externalapi.DomainOutpoint{TransactionID: *current.TransactionID()}
|
outpoint := externalapi.DomainOutpoint{TransactionID: *current.TransactionID()}
|
||||||
for i := range current.Transaction().Outputs {
|
for i := range current.Transaction().Outputs {
|
||||||
outpoint.Index = uint32(i)
|
outpoint.Index = uint32(i)
|
||||||
if redeemerTransaction, ok := tp.chainedTransactionsByPreviousOutpoint[outpoint]; ok {
|
if redeemerTransaction, ok := tp.chainedTransactionsByPreviousOutpoint[outpoint]; ok {
|
||||||
queue = append(queue, redeemerTransaction)
|
stack = append(stack, redeemerTransaction)
|
||||||
redeemers = append(redeemers, redeemerTransaction)
|
redeemers = append(redeemers, redeemerTransaction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user