diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-21 01:13:46 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-21 01:13:46 +0800 |
commit | bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca (patch) | |
tree | 46ab5943fd5e26198067aeec4a44287452eb2a32 /state/dump.go | |
parent | 771bfe9e78f9952002a71cccc8d41c8c544fdfcb (diff) | |
parent | d586a633ff005ac01c9f1eb33552d147cf6c883e (diff) | |
download | dexon-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.tar dexon-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.tar.gz dexon-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.tar.bz2 dexon-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.tar.lz dexon-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.tar.xz dexon-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.tar.zst dexon-bd7ebbcd5b77ce4fdd471b44f0acda80f2b3ceca.zip |
Merge branch 'release/0.9.0'
Diffstat (limited to 'state/dump.go')
-rw-r--r-- | state/dump.go | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/state/dump.go b/state/dump.go index c1f5ecf3a..81895f1a3 100644 --- a/state/dump.go +++ b/state/dump.go @@ -22,22 +22,23 @@ type World struct { func (self *StateDB) Dump() []byte { world := World{ - Root: ethutil.Bytes2Hex(self.Trie.GetRoot()), + Root: ethutil.Bytes2Hex(self.trie.Root()), Accounts: make(map[string]Account), } - self.Trie.NewIterator().Each(func(key string, value *ethutil.Value) { - stateObject := NewStateObjectFromBytes([]byte(key), value.Bytes()) + it := self.trie.Iterator() + for it.Next() { + stateObject := NewStateObjectFromBytes(it.Key, it.Value, self.db) - account := Account{Balance: stateObject.balance.String(), Nonce: stateObject.Nonce, Root: ethutil.Bytes2Hex(stateObject.Root()), CodeHash: ethutil.Bytes2Hex(stateObject.codeHash)} + account := Account{Balance: stateObject.balance.String(), Nonce: stateObject.nonce, Root: ethutil.Bytes2Hex(stateObject.Root()), CodeHash: ethutil.Bytes2Hex(stateObject.codeHash)} account.Storage = make(map[string]string) - stateObject.EachStorage(func(key string, value *ethutil.Value) { - value.Decode() - account.Storage[ethutil.Bytes2Hex([]byte(key))] = ethutil.Bytes2Hex(value.Bytes()) - }) - world.Accounts[ethutil.Bytes2Hex([]byte(key))] = account - }) + storageIt := stateObject.State.trie.Iterator() + for storageIt.Next() { + account.Storage[ethutil.Bytes2Hex(it.Key)] = ethutil.Bytes2Hex(it.Value) + } + world.Accounts[ethutil.Bytes2Hex(it.Key)] = account + } json, err := json.MarshalIndent(world, "", " ") if err != nil { @@ -49,8 +50,9 @@ func (self *StateDB) Dump() []byte { // Debug stuff func (self *StateObject) CreateOutputForDiff() { - fmt.Printf("%x %x %x %x\n", self.Address(), self.State.Root(), self.balance.Bytes(), self.Nonce) - self.EachStorage(func(addr string, value *ethutil.Value) { - fmt.Printf("%x %x\n", addr, value.Bytes()) - }) + fmt.Printf("%x %x %x %x\n", self.Address(), self.State.Root(), self.balance.Bytes(), self.nonce) + it := self.State.trie.Iterator() + for it.Next() { + fmt.Printf("%x %x\n", it.Key, it.Value) + } } |