From 96df23c426989d69df44547c402fa2bf561867ea Mon Sep 17 00:00:00 2001 From: Bryan White <bryanchriswhite@gmail.com> Date: Tue, 16 Jul 2024 09:49:36 +0200 Subject: [PATCH] refactor: #length() to #DigestSize() --- root.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/root.go b/root.go index 3d5f841..06da067 100644 --- a/root.go +++ b/root.go @@ -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)