diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-07 20:17:48 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-07 20:17:48 +0800 |
commit | fed3e6a808921fb8274b50043c5c39a24a1bbccf (patch) | |
tree | d632e95cfce78bd9a99a52bf7f30ee3ff980dfd3 /trie | |
parent | 032ab665299d75bffc25260e8fa477ace19db06a (diff) | |
download | go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.gz go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.bz2 go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.lz go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.xz go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.zst go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.zip |
Refactored ethutil.Config.Db out
Diffstat (limited to 'trie')
-rw-r--r-- | trie/iterator.go | 2 | ||||
-rw-r--r-- | trie/trie.go | 14 | ||||
-rw-r--r-- | trie/trie_test.go | 55 |
3 files changed, 9 insertions, 62 deletions
diff --git a/trie/iterator.go b/trie/iterator.go index 53d099a0c..1114715a6 100644 --- a/trie/iterator.go +++ b/trie/iterator.go @@ -1,5 +1,6 @@ package trie +/* import ( "bytes" @@ -141,3 +142,4 @@ func (self *Iterator) Next(key string) []byte { return self.Key } +*/ diff --git a/trie/trie.go b/trie/trie.go index d89c39775..c9fd18e00 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -1,5 +1,6 @@ package trie +/* import ( "bytes" "fmt" @@ -174,11 +175,9 @@ func New(db ethutil.Database, Root interface{}) *Trie { func (self *Trie) setRoot(root interface{}) { switch t := root.(type) { case string: - /* - if t == "" { - root = crypto.Sha3(ethutil.Encode("")) - } - */ + //if t == "" { + // root = crypto.Sha3(ethutil.Encode("")) + //} self.Root = []byte(t) case []byte: self.Root = root @@ -187,10 +186,6 @@ func (self *Trie) setRoot(root interface{}) { } } -/* - * Public (query) interface functions - */ - func (t *Trie) Update(key, value string) { t.mut.Lock() defer t.mut.Unlock() @@ -629,3 +624,4 @@ func (it *TrieIterator) iterateNode(key []byte, currentNode *ethutil.Value, cb E } } } +*/ diff --git a/trie/trie_test.go b/trie/trie_test.go index 207d41f30..3abe56040 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -1,5 +1,6 @@ package trie +/* import ( "bytes" "encoding/hex" @@ -337,59 +338,6 @@ func (s *TrieSuite) TestItems(c *checker.C) { c.Assert(s.trie.GetRoot(), checker.DeepEquals, ethutil.Hex2Bytes(exp)) } -/* -func TestRndCase(t *testing.T) { - _, trie := NewTrie() - - data := []struct{ k, v string }{ - {"0000000000000000000000000000000000000000000000000000000000000001", "a07573657264617461000000000000000000000000000000000000000000000000"}, - {"0000000000000000000000000000000000000000000000000000000000000003", "8453bb5b31"}, - {"0000000000000000000000000000000000000000000000000000000000000004", "850218711a00"}, - {"0000000000000000000000000000000000000000000000000000000000000005", "9462d7705bd0b3ecbc51a8026a25597cb28a650c79"}, - {"0000000000000000000000000000000000000000000000000000000000000010", "947e70f9460402290a3e487dae01f610a1a8218fda"}, - {"0000000000000000000000000000000000000000000000000000000000000111", "01"}, - {"0000000000000000000000000000000000000000000000000000000000000112", "a053656e6174650000000000000000000000000000000000000000000000000000"}, - {"0000000000000000000000000000000000000000000000000000000000000113", "a053656e6174650000000000000000000000000000000000000000000000000000"}, - {"53656e6174650000000000000000000000000000000000000000000000000000", "94977e3f62f5e1ed7953697430303a3cfa2b5b736e"}, - } - for _, e := range data { - trie.Update(string(ethutil.Hex2Bytes(e.k)), string(ethutil.Hex2Bytes(e.v))) - } - - fmt.Printf("root after update %x\n", trie.Root) - trie.NewIterator().Each(func(k string, v *ethutil.Value) { - fmt.Printf("%x %x\n", k, v.Bytes()) - }) - - data = []struct{ k, v string }{ - {"0000000000000000000000000000000000000000000000000000000000000112", ""}, - {"436974697a656e73000000000000000000000000000000000000000000000001", ""}, - {"436f757274000000000000000000000000000000000000000000000000000002", ""}, - {"53656e6174650000000000000000000000000000000000000000000000000000", ""}, - {"436f757274000000000000000000000000000000000000000000000000000000", ""}, - {"53656e6174650000000000000000000000000000000000000000000000000001", ""}, - {"0000000000000000000000000000000000000000000000000000000000000113", ""}, - {"436974697a656e73000000000000000000000000000000000000000000000000", ""}, - {"436974697a656e73000000000000000000000000000000000000000000000002", ""}, - {"436f757274000000000000000000000000000000000000000000000000000001", ""}, - {"0000000000000000000000000000000000000000000000000000000000000111", ""}, - {"53656e6174650000000000000000000000000000000000000000000000000002", ""}, - } - - for _, e := range data { - trie.Delete(string(ethutil.Hex2Bytes(e.k))) - } - - fmt.Printf("root after delete %x\n", trie.Root) - - trie.NewIterator().Each(func(k string, v *ethutil.Value) { - fmt.Printf("%x %x\n", k, v.Bytes()) - }) - - fmt.Printf("%x\n", trie.Get(string(ethutil.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001")))) -} -*/ - func TestOtherSomething(t *testing.T) { _, trie := NewTrie() @@ -445,3 +393,4 @@ func BenchmarkUpdate(b *testing.B) { trie.Update(fmt.Sprintf("aaaaaaaaaaaaaaa%d", i), "value") } } +*/ |