From e3fa68a69abc6ca70cd3af60cf1c88edbab21bac Mon Sep 17 00:00:00 2001 From: Calvin Kim Date: Mon, 24 Jun 2024 20:43:57 +0900 Subject: [PATCH] indexers: only include positions that were found GetLeafPosition returns the position and a boolean indicating whether or not a hash was found. The boolean wasn't being checked which ended up with the hashes that weren't found where being included as a 0. We omit the positions entirely in this commit if they were not found. --- blockchain/indexers/flatutreexoproofindex.go | 6 ++++-- blockchain/indexers/utreexoproofindex.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/blockchain/indexers/flatutreexoproofindex.go b/blockchain/indexers/flatutreexoproofindex.go index f62c14ac..72a77463 100644 --- a/blockchain/indexers/flatutreexoproofindex.go +++ b/blockchain/indexers/flatutreexoproofindex.go @@ -872,8 +872,10 @@ func (idx *FlatUtreexoProofIndex) GenerateUDataPartial(dels []wire.LeafData, pos targets := make([]uint64, len(delHashes)) for i, delHash := range delHashes { - pos, _ := idx.utreexoState.state.GetLeafPosition(delHash) - targets[i] = pos + pos, found := idx.utreexoState.state.GetLeafPosition(delHash) + if found { + targets[i] = pos + } } ud.AccProof = utreexo.Proof{ diff --git a/blockchain/indexers/utreexoproofindex.go b/blockchain/indexers/utreexoproofindex.go index 8f29f952..27224899 100644 --- a/blockchain/indexers/utreexoproofindex.go +++ b/blockchain/indexers/utreexoproofindex.go @@ -446,8 +446,10 @@ func (idx *UtreexoProofIndex) GenerateUDataPartial(dels []wire.LeafData, positio targets := make([]uint64, len(delHashes)) for i, delHash := range delHashes { - pos, _ := idx.utreexoState.state.GetLeafPosition(delHash) - targets[i] = pos + pos, found := idx.utreexoState.state.GetLeafPosition(delHash) + if found { + targets[i] = pos + } } ud.AccProof = utreexo.Proof{ Targets: targets,