Skip to content

Commit

Permalink
on unmarshaling Merklizer from bytes, set hasher to default if not se…
Browse files Browse the repository at this point in the history
…t with options
  • Loading branch information
olomix committed Sep 25, 2023
1 parent 26587b0 commit 27d81f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion merklize/binary_encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ func (e *RDFEntry) UnmarshalBinary(in []byte) error {
const mzEncodingVersion = 1

func MerklizerFromBytes(in []byte, opts ...MerklizeOption) (*Merklizer, error) {
mz := &Merklizer{safeMode: true}
mz := &Merklizer{
safeMode: true,
hasher: defaultHasher,
}
for _, o := range opts {
o(mz)
}
Expand Down Expand Up @@ -246,6 +249,10 @@ func (mz *Merklizer) UnmarshalBinary(in []byte) error {

addToMT := false

if mz.hasher == nil {
mz.hasher = defaultHasher
}

// if merkletree is not set with options, initialize new in-memory MT.
if mz.mt == nil {
var mt *merkletree.MerkleTree
Expand Down

0 comments on commit 27d81f8

Please sign in to comment.