aboutsummaryrefslogtreecommitdiffstats
path: root/trie/trie.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-04-18 19:25:07 +0800
committerFelix Lange <fjl@twurst.com>2017-04-25 08:14:31 +0800
commitf958d7d4822d257598ae36fc3b381040faa5bb30 (patch)
tree332291db0e8e1e7a41699aad291e5f13f35e6385 /trie/trie.go
parenta31d268b76ff13df8e7d060163a842b8ed569793 (diff)
downloadgo-tangerine-f958d7d4822d257598ae36fc3b381040faa5bb30.tar
go-tangerine-f958d7d4822d257598ae36fc3b381040faa5bb30.tar.gz
go-tangerine-f958d7d4822d257598ae36fc3b381040faa5bb30.tar.bz2
go-tangerine-f958d7d4822d257598ae36fc3b381040faa5bb30.tar.lz
go-tangerine-f958d7d4822d257598ae36fc3b381040faa5bb30.tar.xz
go-tangerine-f958d7d4822d257598ae36fc3b381040faa5bb30.tar.zst
go-tangerine-f958d7d4822d257598ae36fc3b381040faa5bb30.zip
trie: rework and document key encoding
'encode' and 'decode' are meaningless because the code deals with three encodings. Document the encodings and give a name to each one.
Diffstat (limited to 'trie/trie.go')
-rw-r--r--trie/trie.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/trie/trie.go b/trie/trie.go
index 0979eb625..e61bd0383 100644
--- a/trie/trie.go
+++ b/trie/trie.go
@@ -144,7 +144,7 @@ func (t *Trie) Get(key []byte) []byte {
// The value bytes must not be modified by the caller.
// If a node was not found in the database, a MissingNodeError is returned.
func (t *Trie) TryGet(key []byte) ([]byte, error) {
- key = compactHexDecode(key)
+ key = keybytesToHex(key)
value, newroot, didResolve, err := t.tryGet(t.root, key, 0)
if err == nil && didResolve {
t.root = newroot
@@ -211,7 +211,7 @@ func (t *Trie) Update(key, value []byte) {
//
// If a node was not found in the database, a MissingNodeError is returned.
func (t *Trie) TryUpdate(key, value []byte) error {
- k := compactHexDecode(key)
+ k := keybytesToHex(key)
if len(value) != 0 {
_, n, err := t.insert(t.root, nil, k, valueNode(value))
if err != nil {
@@ -307,7 +307,7 @@ func (t *Trie) Delete(key []byte) {
// TryDelete removes any existing value for key from the trie.
// If a node was not found in the database, a MissingNodeError is returned.
func (t *Trie) TryDelete(key []byte) error {
- k := compactHexDecode(key)
+ k := keybytesToHex(key)
_, n, err := t.delete(t.root, nil, k)
if err != nil {
return err