aboutsummaryrefslogtreecommitdiffstats
path: root/state/dump.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-24 01:35:36 +0800
committerobscuren <geffobscura@gmail.com>2014-12-24 01:35:36 +0800
commit780abaec988df302e0c98f1a35e9af35b5623746 (patch)
treedfd26765ec08d3df756730bb186639edb388b4ee /state/dump.go
parent1054c155db8ac59b97b81fa7a7a20f2239eb1e82 (diff)
downloadgo-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.gz
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.bz2
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.lz
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.xz
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.zst
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.zip
Switched to new trie
Diffstat (limited to 'state/dump.go')
-rw-r--r--state/dump.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/state/dump.go b/state/dump.go
index c1f5ecf3a..40ecff50c 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)
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 {
@@ -50,7 +51,8 @@ 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())
- })
+ it := self.State.trie.Iterator()
+ for it.Next() {
+ fmt.Printf("%x %x\n", it.Key, it.Value)
+ }
}