diff options
author | Felix Lange <fjl@twurst.com> | 2015-12-11 08:29:41 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-12-18 19:09:10 +0800 |
commit | 1b89bd5d269d2d85a7c72067e18212135d8757f9 (patch) | |
tree | b6d3cf1bd43f14699f6a5fdcb7a6232c6b6c1044 /core/state/statedb.go | |
parent | 9be5d5cd90517244b239c6af4e602d898fafeaf7 (diff) | |
download | dexon-1b89bd5d269d2d85a7c72067e18212135d8757f9.tar dexon-1b89bd5d269d2d85a7c72067e18212135d8757f9.tar.gz dexon-1b89bd5d269d2d85a7c72067e18212135d8757f9.tar.bz2 dexon-1b89bd5d269d2d85a7c72067e18212135d8757f9.tar.lz dexon-1b89bd5d269d2d85a7c72067e18212135d8757f9.tar.xz dexon-1b89bd5d269d2d85a7c72067e18212135d8757f9.tar.zst dexon-1b89bd5d269d2d85a7c72067e18212135d8757f9.zip |
core/state, core/types use package rlp for state, receipt serialisation
Diffstat (limited to 'core/state/statedb.go')
-rw-r--r-- | core/state/statedb.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go index a9de71409..ab93870bf 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -18,6 +18,7 @@ package state import ( + "fmt" "math/big" "github.com/ethereum/go-ethereum/common" @@ -25,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" ) @@ -205,13 +207,15 @@ func (self *StateDB) Delete(addr common.Address) bool { // Update the given state object and apply it to state trie func (self *StateDB) UpdateStateObject(stateObject *StateObject) { - //addr := stateObject.Address() - - if len(stateObject.CodeHash()) > 0 { - self.db.Put(stateObject.CodeHash(), stateObject.code) + if len(stateObject.code) > 0 { + self.db.Put(stateObject.codeHash, stateObject.code) } addr := stateObject.Address() - self.trie.Update(addr[:], stateObject.RlpEncode()) + data, err := rlp.EncodeToBytes(stateObject) + if err != nil { + panic(fmt.Errorf("can't encode object at %x: %v", addr[:], err)) + } + self.trie.Update(addr[:], data) } // Delete the given state object and delete it from the state trie @@ -238,10 +242,12 @@ func (self *StateDB) GetStateObject(addr common.Address) (stateObject *StateObje if len(data) == 0 { return nil } - - stateObject = NewStateObjectFromBytes(addr, []byte(data), self.db) + stateObject, err := DecodeObject(addr, self.db, data) + if err != nil { + glog.Errorf("can't decode object at %x: %v", addr[:], err) + return nil + } self.SetStateObject(stateObject) - return stateObject } |