Skip to content

Commit

Permalink
refactor: #length() to #DigestSize()
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Jul 16, 2024
1 parent 934fc19 commit 96df23c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,26 @@ func (root MerkleSumRoot) Count() (uint64, error) {
return root.count(), nil
}

// DigestSize returns the length of the digest portion of the root.
func (root MerkleSumRoot) DigestSize() int {
return len(root) - countSizeBytes - sumSizeBytes
}

// HasDigestSize returns true if the root hash (digest) length is the same as
// that of the size of the given hasher.
func (root MerkleSumRoot) HasDigestSize(size int) bool {
return root.length() == size
return root.DigestSize() == size
}

// validateBasic returns an error if the root (digest) length is not a power of two.
func (root MerkleSumRoot) validateBasic() error {
if !isPowerOfTwo(root.length()) {
if !isPowerOfTwo(root.DigestSize()) {
return fmt.Errorf("MerkleSumRoot#validateBasic: invalid root length")
}

return nil
}

// length returns the length of the digest portion of the root.
func (root MerkleSumRoot) length() int {
return len(root) - countSizeBytes - sumSizeBytes
}

// sum returns the sum of the node stored in the root.
func (root MerkleSumRoot) sum() uint64 {
firstSumByteIdx, firstCountByteIdx := getFirstMetaByteIdx(root)
Expand Down

0 comments on commit 96df23c

Please sign in to comment.