From 3ad89a27e907038761e728e332b1cf8f3a6bb7cd Mon Sep 17 00:00:00 2001 From: Krzysztof Tomecki <152964795+chris-4chain@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:30:26 +0100 Subject: [PATCH] feat(SPV-1337): no collect ancestors utils function --- engine/utils/collect_ancestors.go | 42 ------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 engine/utils/collect_ancestors.go diff --git a/engine/utils/collect_ancestors.go b/engine/utils/collect_ancestors.go deleted file mode 100644 index db88a42ab..000000000 --- a/engine/utils/collect_ancestors.go +++ /dev/null @@ -1,42 +0,0 @@ -package utils - -import ( - "iter" - "maps" - - trx "github.com/bitcoin-sv/go-sdk/transaction" -) - -// CollectAncestors Gets the ancestors (up to mined) of provided transaction with no duplicates and excluding itself -func CollectAncestors(tx *trx.Transaction) iter.Seq[*trx.Transaction] { - stack := make([]*trx.Transaction, 0) - - it := func(yield func(string, *trx.Transaction) bool) { - if tx.MerklePath != nil { - // empty result if provided transaction is already mined - return - } - stack = append(stack, tx) - for len(stack) > 0 { - t := stack[len(stack)-1] - stack = stack[:len(stack)-1] - - for _, input := range t.Inputs { - if input.SourceTransaction == nil { - continue - } - - // collect source transaction of the input - yield(input.SourceTransaction.TxID().String(), input.SourceTransaction) - - if input.SourceTransaction.MerklePath != nil { - // don't process source transaction if it's already mined - continue - } - stack = append(stack, input.SourceTransaction) - } - } - } - - return maps.Values(maps.Collect(it)) -}