diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-04 06:45:44 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-04 06:45:44 +0800 |
commit | a82b89e2d524a9b7f758dc2d981e8af835d8cd2a (patch) | |
tree | ae3c3c3c8bdd24f1a76c455338c42635a2d1385a /state | |
parent | c8302882c87afffeb7d9241060e24984a04cb8eb (diff) | |
download | go-tangerine-a82b89e2d524a9b7f758dc2d981e8af835d8cd2a.tar.gz go-tangerine-a82b89e2d524a9b7f758dc2d981e8af835d8cd2a.tar.zst go-tangerine-a82b89e2d524a9b7f758dc2d981e8af835d8cd2a.zip |
Added storage root to dump
Diffstat (limited to 'state')
-rw-r--r-- | state/dump.go | 3 | ||||
-rw-r--r-- | state/state_object.go | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/state/dump.go b/state/dump.go index de356f476..a7057b445 100644 --- a/state/dump.go +++ b/state/dump.go @@ -10,6 +10,7 @@ import ( type Account struct { Balance string `json:"balance"` Nonce uint64 `json:"nonce"` + Root string `json:"root"` CodeHash string `json:"codeHash"` Storage map[string]string `json:"storage"` } @@ -28,7 +29,7 @@ func (self *State) Dump() []byte { self.Trie.NewIterator().Each(func(key string, value *ethutil.Value) { stateObject := NewStateObjectFromBytes([]byte(key), value.Bytes()) - account := Account{Balance: stateObject.balance.String(), Nonce: stateObject.Nonce, 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) { diff --git a/state/state_object.go b/state/state_object.go index 472aa8389..70a1766ce 100644 --- a/state/state_object.go +++ b/state/state_object.go @@ -283,6 +283,10 @@ func (self *StateObject) Object() *StateObject { return self } +func (self *StateObject) Root() []byte { + return self.State.Trie.GetRoot() +} + // Debug stuff func (self *StateObject) CreateOutputForDiff() { fmt.Printf("%x %x %x %x\n", self.Address(), self.State.Root(), self.balance.Bytes(), self.Nonce) @@ -297,6 +301,7 @@ func (self *StateObject) CreateOutputForDiff() { // State object encoding methods func (c *StateObject) RlpEncode() []byte { + fmt.Printf("%x %x\n", c.State.Trie.Root, c.CodeHash()) return ethutil.Encode([]interface{}{c.Nonce, c.balance, c.State.Trie.Root, c.CodeHash()}) } |