diff options
-rw-r--r-- | ethdb/database.go | 1 | ||||
-rw-r--r-- | state/dump.go | 3 | ||||
-rw-r--r-- | state/state_object.go | 5 | ||||
-rw-r--r-- | trie/trie.go | 2 |
4 files changed, 8 insertions, 3 deletions
diff --git a/ethdb/database.go b/ethdb/database.go index a59782047..19aa83466 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -47,7 +47,6 @@ func (self *LDBDatabase) Get(key []byte) ([]byte, error) { } if self.comp { - //fmt.Println("get", dat) return rle.Decompress(dat) } 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()}) } diff --git a/trie/trie.go b/trie/trie.go index b442abfe3..d5ab2035a 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -178,7 +178,7 @@ func (self *Trie) setRoot(root interface{}) { switch t := root.(type) { case string: if t == "" { - root = crypto.Sha3([]byte("")) + root = crypto.Sha3(ethutil.Encode("")) } self.Root = root case []byte: |