From e3e6ed5a282ad3cc3b046713f426fcc6ea57c5e7 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 12 Jul 2024 13:03:16 +0200 Subject: [PATCH] chore: self Signed-off-by: Bryan White --- root.go | 6 ++++-- smst.go | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/root.go b/root.go index 0613fb8..faf315c 100644 --- a/root.go +++ b/root.go @@ -36,7 +36,8 @@ func (r MerkleSumRoot) Sum() (uint64, error) { } // MustCount returns the uint64 count of the merkle root, a cryptographically secure -// count of the number of non-empty leafs in the tree. +// count of the number of non-empty leafs in the tree. It panics if the root hash length +// does not match that of the SMST hasher. func (r MerkleSumRoot) MustCount() uint64 { count, err := r.Count() if err != nil { @@ -47,7 +48,8 @@ func (r MerkleSumRoot) MustCount() uint64 { } // Count returns the uint64 count of the merkle root, a cryptographically secure -// count of the number of non-empty leafs in the tree. +// count of the number of non-empty leafs in the tree. It returns an error if the root hash length +// does not match that of the SMST hasher. func (r MerkleSumRoot) Count() (uint64, error) { if len(r) != SmstRootSizeBytes { return 0, fmt.Errorf("MerkleSumRoot#Count: not a merkle sum trie") diff --git a/smst.go b/smst.go index 09b5128..5559c32 100644 --- a/smst.go +++ b/smst.go @@ -186,7 +186,7 @@ func (smst *SMST) MustSum() uint64 { } // Sum returns the sum of the entire trie stored in the root. -// If the tree is not a sum tree, it will panic. +// If the tree is not a sum tree, it will return an error. func (smst *SMST) Sum() (uint64, error) { if !smst.Spec().sumTrie { return 0, fmt.Errorf("SMST: not a merkle sum trie") @@ -196,6 +196,7 @@ func (smst *SMST) Sum() (uint64, error) { } // MustCount returns the number of non-empty nodes in the entire trie stored in the root. +// If the tree is not a sum tree, it will panic. func (smst *SMST) MustCount() uint64 { count, err := smst.Count() if err != nil { @@ -205,6 +206,7 @@ func (smst *SMST) MustCount() uint64 { } // Count returns the number of non-empty nodes in the entire trie stored in the root. +// If the tree is not a sum tree, it will return an error. func (smst *SMST) Count() (uint64, error) { if !smst.Spec().sumTrie { return 0, fmt.Errorf("SMST: not a merkle sum trie")