diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-26 06:42:07 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-26 06:42:07 +0800 |
commit | b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db (patch) | |
tree | 96e360fc19b7c0a37172d6d27d1221bf175228e6 /ethutil | |
parent | 4e1c6a8a22924d06a2a972c024891cebcf8ea054 (diff) | |
parent | 1f3f76cb092e84bd2e90950f0d43d7657eae878e (diff) | |
download | go-tangerine-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar go-tangerine-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.gz go-tangerine-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.bz2 go-tangerine-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.lz go-tangerine-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.xz go-tangerine-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.zst go-tangerine-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.zip |
Merge branch 'release/poc5-rc9'
Diffstat (limited to 'ethutil')
-rw-r--r-- | ethutil/config.go | 12 | ||||
-rw-r--r-- | ethutil/trie_test.go | 17 | ||||
-rw-r--r-- | ethutil/value.go | 2 |
3 files changed, 25 insertions, 6 deletions
diff --git a/ethutil/config.go b/ethutil/config.go index 1b41c4634..40ab3aa69 100644 --- a/ethutil/config.go +++ b/ethutil/config.go @@ -19,6 +19,7 @@ type config struct { Ver string ClientString string Pubkey []byte + Identifier string } var Config *config @@ -26,7 +27,7 @@ var Config *config // Read config // // Initialize the global Config variable with default settings -func ReadConfig(base string, logTypes LoggerType) *config { +func ReadConfig(base string, logTypes LoggerType, id string) *config { if Config == nil { usr, _ := user.Current() path := path.Join(usr.HomeDir, base) @@ -42,7 +43,8 @@ func ReadConfig(base string, logTypes LoggerType) *config { } } - Config = &config{ExecPath: path, Debug: true, Ver: "0.5.0 RC8"} + Config = &config{ExecPath: path, Debug: true, Ver: "0.5.0 RC9"} + Config.Identifier = id Config.Log = NewLogger(logTypes, LogLevelDebug) Config.SetClientString("/Ethereum(G)") } @@ -53,7 +55,11 @@ func ReadConfig(base string, logTypes LoggerType) *config { // Set client string // func (c *config) SetClientString(str string) { - Config.ClientString = fmt.Sprintf("%s nv%s/%s", str, c.Ver, runtime.GOOS) + id := runtime.GOOS + if len(c.Identifier) > 0 { + id = c.Identifier + } + Config.ClientString = fmt.Sprintf("%s nv%s/%s", str, c.Ver, id) } type LoggerType byte diff --git a/ethutil/trie_test.go b/ethutil/trie_test.go index 0be512d9f..d74d129ac 100644 --- a/ethutil/trie_test.go +++ b/ethutil/trie_test.go @@ -1,7 +1,7 @@ package ethutil import ( - _ "fmt" + "fmt" "reflect" "testing" ) @@ -26,7 +26,6 @@ func (db *MemDatabase) Delete(key []byte) error { delete(db.db, string(key)) return nil } -func (db *MemDatabase) GetKeys() []*Key { return nil } func (db *MemDatabase) Print() {} func (db *MemDatabase) Close() {} func (db *MemDatabase) LastKnownTD() []byte { return nil } @@ -171,3 +170,17 @@ func TestTrieIterator(t *testing.T) { t.Errorf("Expected cached nodes to be deleted") } } + +func TestHashes(t *testing.T) { + _, trie := New() + trie.Update("cat", "dog") + trie.Update("ca", "dude") + trie.Update("doge", "1234567890abcdefghijklmnopqrstuvwxxzABCEFGHIJKLMNOPQRSTUVWXYZ") + trie.Update("dog", "test") + trie.Update("test", "1234567890abcdefghijklmnopqrstuvwxxzABCEFGHIJKLMNOPQRSTUVWXYZ") + fmt.Printf("%x\n", trie.Root) + trie.Delete("dog") + fmt.Printf("%x\n", trie.Root) + trie.Delete("test") + fmt.Printf("%x\n", trie.Root) +} diff --git a/ethutil/value.go b/ethutil/value.go index b7756f9b1..83600abc2 100644 --- a/ethutil/value.go +++ b/ethutil/value.go @@ -16,7 +16,7 @@ type Value struct { } func (val *Value) String() string { - return fmt.Sprintf("%q", val.Val) + return fmt.Sprintf("%x", val.Val) } func NewValue(val interface{}) *Value { |