Skip to content

Commit

Permalink
returns the error returned by validateRange
Browse files Browse the repository at this point in the history
  • Loading branch information
staheri14 committed Apr 26, 2023
1 parent 167629c commit fcd3cd0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ func (n *NamespacedMerkleTree) ProveNamespace(nID namespace.ID) (Proof, error) {
}

// validateRange validates the range [start, end) against the size of the tree.
// start is inclusive and end is non-inclusive.
func (n *NamespacedMerkleTree) validateRange(start, end int) error {
if start < 0 || start >= end || end > len(n.leaves) {
return ErrInvalidRange
Expand All @@ -263,7 +264,7 @@ func (n *NamespacedMerkleTree) buildRangeProof(proofStart, proofEnd int) ([][]by

// validate the range
if err := n.validateRange(proofStart, proofEnd); err != nil {
return nil, ErrInvalidRange
return nil, err
}

// start, end are indices of leaves in the tree hence they should be within
Expand Down

0 comments on commit fcd3cd0

Please sign in to comment.