merkletree: add CollapsedTree.Equal
This commit is contained in:
parent
eb16a10c2e
commit
84de749c8c
|
@ -13,6 +13,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"math/bits"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type CollapsedTree struct {
|
||||
|
@ -41,6 +42,10 @@ func CloneCollapsedTree(source *CollapsedTree) *CollapsedTree {
|
|||
return &CollapsedTree{nodes: nodes, size: source.size}
|
||||
}
|
||||
|
||||
func (tree CollapsedTree) Equal(other CollapsedTree) bool {
|
||||
return tree.size == other.size && slices.Equal(tree.nodes, other.nodes)
|
||||
}
|
||||
|
||||
func (tree *CollapsedTree) Add(hash Hash) {
|
||||
tree.nodes = append(tree.nodes, hash)
|
||||
tree.size++
|
||||
|
|
Loading…
Reference in New Issue