Skip to content

Commit

Permalink
Add GetKey method to node interface
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Dec 9, 2021
1 parent a6f60df commit 6f38613
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/trie/node/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ import (
"github.com/ChainSafe/gossamer/internal/trie/pools"
)

// GetKey returns the key of the branch.
// Note it does not copy the byte slice so modifying the returned
// byte slice will modify the byte slice of the branch.
func (b *Branch) GetKey() (value []byte) {
return b.Key
}

// GetKey returns the key of the leaf.
// Note it does not copy the byte slice so modifying the returned
// byte slice will modify the byte slice of the leaf.
func (l *Leaf) GetKey() (value []byte) {
return l.Key
}

// SetKey sets the key to the branch.
// Note it does not copy it so modifying the passed key
// will modify the key stored in the branch.
Expand Down
1 change: 1 addition & 0 deletions internal/trie/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Node interface {
String() string
SetEncodingAndHash(encoding []byte, hash []byte)
GetHash() (hash []byte)
GetKey() (key []byte)
GetValue() (value []byte)
GetGeneration() (generation uint64)
SetGeneration(generation uint64)
Expand Down

0 comments on commit 6f38613

Please sign in to comment.