Skip to content

Commit a62b805

Browse files
committed
implement Copy and toDot for HashedNode
Signed-off-by: Guillaume Ballet <[email protected]>
1 parent 5eee1c3 commit a62b805

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

trie/binary.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ func (h HashedNode) Commit() common.Hash {
132132
}
133133

134134
func (h HashedNode) Copy() BinaryNode {
135-
panic("not implemented") // TODO: Implement
135+
var nh common.Hash
136+
nh = common.Hash(h)
137+
return HashedNode(nh)
136138
}
137139

138140
func (h HashedNode) Hash() common.Hash {
@@ -161,7 +163,10 @@ func (h HashedNode) InsertValuesAtStem(key []byte, values [][]byte, resolver Nod
161163
}
162164

163165
func (h HashedNode) toDot(parent string, path string) string {
164-
panic("not implemented") // TODO: Implement
166+
me := fmt.Sprintf("hash%s", path)
167+
ret := fmt.Sprintf("%s [label=\"%x\"]\n", me, h)
168+
ret = fmt.Sprintf("%s %s -> %s\n", ret, parent, me)
169+
return ret
165170
}
166171

167172
func (h HashedNode) CollectNodes([]byte, NodeFlushFn) error {

0 commit comments

Comments
 (0)