Skip to content

Commit

Permalink
Add TODO comment on EncodeAndHash
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jul 20, 2022
1 parent f34baec commit 4acacd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions internal/trie/node/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ func (n *Node) MerkleValue(isRoot bool) (merkleValue []byte, err error) {
// EncodeAndHash returns the encoding of the node and the
// Merkle value of the node. See the `MerkleValue` and `MerkleValueRoot`
// methods for more details on the value of the Merkle value.
// TODO change this function to write to an encoding writer
// and a merkle value writer, such that buffer sync pools can be used
// by the caller.
func (n *Node) EncodeAndHash(isRoot bool) (encoding, merkleValue []byte, err error) {
if !n.Dirty && n.Encoding != nil && n.HashDigest != nil {
return n.Encoding, n.HashDigest, nil
Expand Down
7 changes: 4 additions & 3 deletions lib/trie/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,10 @@ func Test_Trie_Hash(t *testing.T) {
Descendants: 1,
Children: padRightChildren([]*Node{
{
Key: []byte{9},
Value: []byte{1},
Encoding: []byte{0x41, 0x09, 0x04, 0x01},
Key: []byte{9},
Value: []byte{1},
Encoding: []byte{0x41, 0x09, 0x04, 0x01},
HashDigest: []byte{0x41, 0x09, 0x04, 0x01},
},
}),
},
Expand Down

0 comments on commit 4acacd8

Please sign in to comment.