Skip to content

Commit

Permalink
change proof query error (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cha authored Nov 18, 2024
1 parent d22889e commit 3ec9bfd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion merkle/merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,10 @@ func (m *Merkle) GetProofs(leafIndex uint64) (proofs [][]byte, treeIndex uint64,
}

// Check if the leaf index is in the tree
if leafIndex < treeInfo.StartLeafIndex || leafIndex-treeInfo.StartLeafIndex >= treeInfo.LeafCount {
if leafIndex < treeInfo.StartLeafIndex {
return nil, 0, nil, nil, fmt.Errorf("leaf (`%d`) is not found in tree (`%d`)", leafIndex, treeInfo.TreeIndex)
} else if leafIndex-treeInfo.StartLeafIndex >= treeInfo.LeafCount {
return nil, 0, nil, nil, fmt.Errorf("the tree containing the leaf (`%d`) has not been finalized yet", leafIndex)
}

height := uint8(0)
Expand Down

0 comments on commit 3ec9bfd

Please sign in to comment.