From 1b441660abe70dfd0201cec780407f3f50013f60 Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Wed, 16 Oct 2024 08:23:22 -0400 Subject: [PATCH] merkletree: replace IsComplete with more useful ContainsFirstN --- merkletree/fragment.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/merkletree/fragment.go b/merkletree/fragment.go index 4d82502..a679c72 100644 --- a/merkletree/fragment.go +++ b/merkletree/fragment.go @@ -90,8 +90,9 @@ func (tree FragmentedCollapsedTree) Subtrees() []CollapsedTree { } } -func (tree FragmentedCollapsedTree) IsComplete(size uint64) bool { - return len(tree.subtrees) == 1 && tree.subtrees[0].offset == 0 && tree.subtrees[0].size == size +// Return true iff the tree contains at least the first n nodes (without any gaps) +func (tree FragmentedCollapsedTree) ContainsFirstN(n uint64) bool { + return len(tree.subtrees) >= 1 && tree.subtrees[0].offset == 0 && tree.subtrees[0].size >= n } func (tree *FragmentedCollapsedTree) Init(subtrees []CollapsedTree) error {