diff --git a/proofs.go b/proofs.go index 6a09fe9..be33a8f 100644 --- a/proofs.go +++ b/proofs.go @@ -346,7 +346,7 @@ func VerifyClosestProof(proof *SparseMerkleClosestProof, root []byte, spec *Trie // will invalidate the proof. nilSpec := &TrieSpec{ th: spec.th, - ph: newNilPathHasher(spec.ph.PathSize()), + ph: NewNilPathHasher(spec.ph.PathSize()), vh: spec.vh, sumTrie: spec.sumTrie, } diff --git a/types.go b/types.go index f860bba..61b0638 100644 --- a/types.go +++ b/types.go @@ -87,11 +87,16 @@ type TrieSpec struct { sumTrie bool } -func NewTrieSpec(hasher hash.Hash, sumTrie bool) TrieSpec { +func NewTrieSpec(hasher hash.Hash, sumTrie bool, opts ...Option) TrieSpec { spec := TrieSpec{th: *newTrieHasher(hasher)} spec.ph = &pathHasher{spec.th} spec.vh = &valueHasher{spec.th} spec.sumTrie = sumTrie + + for _, opt := range opts { + opt(&spec) + } + return spec } diff --git a/utils.go b/utils.go index cc5bca8..64e98cb 100644 --- a/utils.go +++ b/utils.go @@ -10,8 +10,8 @@ type nilPathHasher struct { func (n *nilPathHasher) Path(key []byte) []byte { return key[:n.hashSize] } func (n *nilPathHasher) PathSize() int { return n.hashSize } - -func newNilPathHasher(hashSize int) PathHasher { + +func NewNilPathHasher(hashSize int) PathHasher { return &nilPathHasher{hashSize: hashSize} }