aboutsummaryrefslogtreecommitdiffstats
path: root/ethtrie/encoding.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-10 23:00:06 +0800
committerobscuren <geffobscura@gmail.com>2014-10-10 23:00:06 +0800
commite02c0fa8088943bc995d290e58a7226f4a0ece91 (patch)
tree1bc2ac212b46d3892dd2720304efb2ab97e43528 /ethtrie/encoding.go
parent9b494c68698cbcaa4d8d6e0f2b964d29db815da5 (diff)
downloadgo-tangerine-e02c0fa8088943bc995d290e58a7226f4a0ece91.tar
go-tangerine-e02c0fa8088943bc995d290e58a7226f4a0ece91.tar.gz
go-tangerine-e02c0fa8088943bc995d290e58a7226f4a0ece91.tar.bz2
go-tangerine-e02c0fa8088943bc995d290e58a7226f4a0ece91.tar.lz
go-tangerine-e02c0fa8088943bc995d290e58a7226f4a0ece91.tar.xz
go-tangerine-e02c0fa8088943bc995d290e58a7226f4a0ece91.tar.zst
go-tangerine-e02c0fa8088943bc995d290e58a7226f4a0ece91.zip
Added generic big to 256 method. Implemented new iterator
Diffstat (limited to 'ethtrie/encoding.go')
-rw-r--r--ethtrie/encoding.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/ethtrie/encoding.go b/ethtrie/encoding.go
index c9c391110..bcf2c5669 100644
--- a/ethtrie/encoding.go
+++ b/ethtrie/encoding.go
@@ -6,7 +6,7 @@ import (
"strings"
)
-func CompactEncode(hexSlice []int) string {
+func CompactEncode(hexSlice []byte) string {
terminator := 0
if hexSlice[len(hexSlice)-1] == 16 {
terminator = 1
@@ -17,11 +17,11 @@ func CompactEncode(hexSlice []int) string {
}
oddlen := len(hexSlice) % 2
- flags := 2*terminator + oddlen
+ flags := byte(2*terminator + oddlen)
if oddlen != 0 {
- hexSlice = append([]int{flags}, hexSlice...)
+ hexSlice = append([]byte{flags}, hexSlice...)
} else {
- hexSlice = append([]int{flags, 0}, hexSlice...)
+ hexSlice = append([]byte{flags, 0}, hexSlice...)
}
var buff bytes.Buffer
@@ -32,7 +32,7 @@ func CompactEncode(hexSlice []int) string {
return buff.String()
}
-func CompactDecode(str string) []int {
+func CompactDecode(str string) []byte {
base := CompactHexDecode(str)
base = base[:len(base)-1]
if base[0] >= 2 {
@@ -47,20 +47,20 @@ func CompactDecode(str string) []int {
return base
}
-func CompactHexDecode(str string) []int {
+func CompactHexDecode(str string) []byte {
base := "0123456789abcdef"
- hexSlice := make([]int, 0)
+ hexSlice := make([]byte, 0)
enc := hex.EncodeToString([]byte(str))
for _, v := range enc {
- hexSlice = append(hexSlice, strings.IndexByte(base, byte(v)))
+ hexSlice = append(hexSlice, byte(strings.IndexByte(base, byte(v))))
}
hexSlice = append(hexSlice, 16)
return hexSlice
}
-func DecodeCompact(key []int) string {
+func DecodeCompact(key []byte) string {
base := "0123456789abcdef"
var str string