core, internal: fix up the state caching

This commit is contained in:
Péter Szilágyi 2016-09-23 08:16:52 +03:00
parent 9d9c64b950
commit c9f5e4db76
4 changed files with 7 additions and 7 deletions

View file

@ -79,7 +79,7 @@ func ExampleGenerateChain() {
evmux := &event.TypeMux{}
blockchain, _ := NewBlockChain(db, MakeChainConfig(), FakePow{}, evmux)
if i, err := blockchain.InsertChain(chain); err != nil {
fmt.Printf("insert error (block %d): %v\n", i, err)
fmt.Printf("insert error (block %d): %v\n", chain[i].NumberU64(), err)
return
}

View file

@ -193,8 +193,6 @@ func (self *StateObject) CommitTrie(db trie.Database, dbw trie.DatabaseWriter) e
fmt.Println("dbErr:", self.dbErr)
return self.dbErr
}
self.dbErr = nil
root, err := self.trie.CommitTo(dbw)
if err == nil {
self.data.Root = root
@ -253,7 +251,7 @@ func (c *StateObject) Address() common.Address {
return c.address
}
// LoadCode returns the contract code associated with this object, if any.
// Code returns the contract code associated with this object, if any.
func (self *StateObject) Code(db trie.Database) []byte {
if self.code != nil {
return self.code

View file

@ -265,7 +265,9 @@ func (self *StateDB) GetStateObject(addr common.Address) (stateObject *StateObje
// Use cached account data from the canon state if possible.
if data, ok := self.all[addr]; ok {
return NewObject(addr, data)
obj := NewObject(addr, data)
self.SetStateObject(obj)
return obj
}
// Load the object from the database.

View file

@ -1280,8 +1280,8 @@ func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) {
}
// SetHead rewinds the head of the blockchain to a previous block.
func (api *PrivateDebugAPI) SetHead(number uint64) {
api.b.SetHead(number)
func (api *PrivateDebugAPI) SetHead(number rpc.HexNumber) {
api.b.SetHead(uint64(number.Int64()))
}
// PublicNetAPI offers network related RPC methods