Skip to content

Commit

Permalink
SetValue method on Node interface
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Dec 8, 2021
1 parent be205de commit f46613f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/trie/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Node interface {
IsDirty() bool
SetDirty(dirty bool)
SetKey(key []byte)
SetValue(value []byte)
String() string
SetEncodingAndHash(encoding []byte, hash []byte)
GetHash() (hash []byte)
Expand Down
14 changes: 14 additions & 0 deletions internal/trie/node/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@ func (b *Branch) GetValue() (value []byte) {
func (l *Leaf) GetValue() (value []byte) {
return l.Value
}

// SetValue sets the byte slice given to the value of the branch.
// Note it does not copy the byte slice so modifying the passed
// byte slice will modify the byte slice of the branch.
func (b *Branch) SetValue(value []byte) {
b.Value = value
}

// SetValue sets the byte slice given to the value of the leaf.
// Note it does not copy the byte slice so modifying the passed
// byte slice will modify the byte slice of the leaf.
func (l *Leaf) SetValue(value []byte) {
l.Value = value
}

0 comments on commit f46613f

Please sign in to comment.