diff --git a/internal/trie/node/key.go b/internal/trie/node/key.go index eddfa1e099f..c1dfd568657 100644 --- a/internal/trie/node/key.go +++ b/internal/trie/node/key.go @@ -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. diff --git a/internal/trie/node/node.go b/internal/trie/node/node.go index 178032aa960..6c306979bbe 100644 --- a/internal/trie/node/node.go +++ b/internal/trie/node/node.go @@ -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)