Skip to content

Commit

Permalink
docs: add comment to leaf case in verify subtree roots inclusion (#272)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **Documentation**
- Enhanced clarity of error handling in the verification process by
adding explanatory comments regarding invalid ranges.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Rootul P <rootulp@gmail.com>
  • Loading branch information
rach-id and rootulp committed Aug 27, 2024
1 parent cce31e8 commit 29e9433
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ func (proof Proof) VerifySubtreeRootInclusion(nth *NmtHasher, subtreeRoots [][]b
}

if end-start == 1 {
// At this level, we reached a leaf, but we couldn't find any range corresponding
// to needed leaf [start, end).
// This means that the initial provided [start, end) range was invalid.
return nil, fmt.Errorf("the provided range [%d, %d) does not reference a valid inner node", proof.start, proof.end)
}

Expand Down

0 comments on commit 29e9433

Please sign in to comment.