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