aboutsummaryrefslogtreecommitdiffstats
path: root/trie/encoding.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-12-18 19:40:01 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-12-18 19:40:01 +0800
commitfd69d2b7a87d9f00854e7d8939a6b3ab53cf8c9b (patch)
tree4d383884e36cf921bdfcfab40235488a60d2729c /trie/encoding.go
parent2baf1de00df56dee47161ad763788a92693b9c29 (diff)
parentef422ee1e1eef831c681aaec31ce7da23b12ae6d (diff)
downloaddexon-fd69d2b7a87d9f00854e7d8939a6b3ab53cf8c9b.tar
dexon-fd69d2b7a87d9f00854e7d8939a6b3ab53cf8c9b.tar.gz
dexon-fd69d2b7a87d9f00854e7d8939a6b3ab53cf8c9b.tar.bz2
dexon-fd69d2b7a87d9f00854e7d8939a6b3ab53cf8c9b.tar.lz
dexon-fd69d2b7a87d9f00854e7d8939a6b3ab53cf8c9b.tar.xz
dexon-fd69d2b7a87d9f00854e7d8939a6b3ab53cf8c9b.tar.zst
dexon-fd69d2b7a87d9f00854e7d8939a6b3ab53cf8c9b.zip
Merge pull request #2019 from zsfelfoldi/light-state
Light state
Diffstat (limited to 'trie/encoding.go')
-rw-r--r--trie/encoding.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/trie/encoding.go b/trie/encoding.go
index 3c172b843..761bad188 100644
--- a/trie/encoding.go
+++ b/trie/encoding.go
@@ -69,6 +69,27 @@ func compactHexDecode(str []byte) []byte {
return nibbles
}
+// compactHexEncode encodes a series of nibbles into a byte array
+func compactHexEncode(nibbles []byte) []byte {
+ nl := len(nibbles)
+ if nl == 0 {
+ return nil
+ }
+ if nibbles[nl-1] == 16 {
+ nl--
+ }
+ l := (nl + 1) / 2
+ var str = make([]byte, l)
+ for i, _ := range str {
+ b := nibbles[i*2] * 16
+ if nl > i*2 {
+ b += nibbles[i*2+1]
+ }
+ str[i] = b
+ }
+ return str
+}
+
func decodeCompact(key []byte) []byte {
l := len(key) / 2
var res = make([]byte, l)