Skip to content

Commit

Permalink
indexers: only include positions that were found
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kcalvinalvin committed Jun 27, 2024
1 parent 24f29d8 commit e3fa68a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions blockchain/indexers/flatutreexoproofindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
6 changes: 4 additions & 2 deletions blockchain/indexers/utreexoproofindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e3fa68a

Please sign in to comment.