aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/bytes.go3
-rw-r--r--ethutil/config.go2
-rw-r--r--ethutil/trie_test.go23
-rw-r--r--ethutil/value.go2
4 files changed, 21 insertions, 9 deletions
diff --git a/ethutil/bytes.go b/ethutil/bytes.go
index bd0df68ec..5e3ee4a6f 100644
--- a/ethutil/bytes.go
+++ b/ethutil/bytes.go
@@ -5,6 +5,7 @@ import (
"encoding/binary"
"fmt"
"math/big"
+ "strings"
)
// Number to bytes
@@ -91,7 +92,7 @@ func IsHex(str string) bool {
}
func StringToByteFunc(str string, cb func(str string) []byte) (ret []byte) {
- if len(str) > 1 && str[0:2] == "0x" {
+ if len(str) > 1 && str[0:2] == "0x" && !strings.Contains(str, "\n") {
ret = FromHex(str[2:])
} else {
ret = cb(str)
diff --git a/ethutil/config.go b/ethutil/config.go
index a24c39bfe..a573e108b 100644
--- a/ethutil/config.go
+++ b/ethutil/config.go
@@ -75,7 +75,7 @@ func ReadConfig(base string, logTypes LoggerType, g *globalconf.GlobalConf, id s
if Config == nil {
path := ApplicationFolder(base)
- Config = &config{ExecPath: path, Debug: true, Ver: "0.5.13"}
+ Config = &config{ExecPath: path, Debug: true, Ver: "0.5.14"}
Config.conf = g
Config.Identifier = id
Config.Log = NewLogger(logTypes, LogLevelDebug)
diff --git a/ethutil/trie_test.go b/ethutil/trie_test.go
index c89f2fbb7..2937b1525 100644
--- a/ethutil/trie_test.go
+++ b/ethutil/trie_test.go
@@ -173,12 +173,21 @@ func TestTriePurge(t *testing.T) {
func TestTrieIt(t *testing.T) {
_, trie := New()
- trie.Update("c", LONG_WORD)
- trie.Update("ca", LONG_WORD)
- trie.Update("cat", LONG_WORD)
- it := trie.NewIterator()
- it.Each(func(key string, node *Value) {
- fmt.Println(key, ":", node.Str())
- })
+ data := [][]string{
+ {"do", "verb"},
+ {"ether", "wookiedoo"},
+ {"horse", "stallion"},
+ {"shaman", "horse"},
+ {"doge", "coin"},
+ {"ether", ""},
+ {"dog", "puppy"},
+ {"shaman", ""},
+ }
+
+ for _, item := range data {
+ trie.Update(item[0], item[1])
+ }
+
+ fmt.Printf("root %x", trie.Root)
}
diff --git a/ethutil/value.go b/ethutil/value.go
index c86c24a7a..ddd864d8a 100644
--- a/ethutil/value.go
+++ b/ethutil/value.go
@@ -114,6 +114,8 @@ func (val *Value) Str() string {
func (val *Value) Bytes() []byte {
if a, ok := val.Val.([]byte); ok {
return a
+ } else if s, ok := val.Val.(byte); ok {
+ return []byte{s}
}
return []byte{}