mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
core, internal: fix up the state caching
This commit is contained in:
parent
9d9c64b950
commit
c9f5e4db76
4 changed files with 7 additions and 7 deletions
|
|
@ -79,7 +79,7 @@ func ExampleGenerateChain() {
|
||||||
evmux := &event.TypeMux{}
|
evmux := &event.TypeMux{}
|
||||||
blockchain, _ := NewBlockChain(db, MakeChainConfig(), FakePow{}, evmux)
|
blockchain, _ := NewBlockChain(db, MakeChainConfig(), FakePow{}, evmux)
|
||||||
if i, err := blockchain.InsertChain(chain); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,8 +193,6 @@ func (self *StateObject) CommitTrie(db trie.Database, dbw trie.DatabaseWriter) e
|
||||||
fmt.Println("dbErr:", self.dbErr)
|
fmt.Println("dbErr:", self.dbErr)
|
||||||
return self.dbErr
|
return self.dbErr
|
||||||
}
|
}
|
||||||
self.dbErr = nil
|
|
||||||
|
|
||||||
root, err := self.trie.CommitTo(dbw)
|
root, err := self.trie.CommitTo(dbw)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
self.data.Root = root
|
self.data.Root = root
|
||||||
|
|
@ -253,7 +251,7 @@ func (c *StateObject) Address() common.Address {
|
||||||
return c.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 {
|
func (self *StateObject) Code(db trie.Database) []byte {
|
||||||
if self.code != nil {
|
if self.code != nil {
|
||||||
return self.code
|
return self.code
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,9 @@ func (self *StateDB) GetStateObject(addr common.Address) (stateObject *StateObje
|
||||||
|
|
||||||
// Use cached account data from the canon state if possible.
|
// Use cached account data from the canon state if possible.
|
||||||
if data, ok := self.all[addr]; ok {
|
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.
|
// Load the object from the database.
|
||||||
|
|
|
||||||
|
|
@ -1280,8 +1280,8 @@ func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHead rewinds the head of the blockchain to a previous block.
|
// SetHead rewinds the head of the blockchain to a previous block.
|
||||||
func (api *PrivateDebugAPI) SetHead(number uint64) {
|
func (api *PrivateDebugAPI) SetHead(number rpc.HexNumber) {
|
||||||
api.b.SetHead(number)
|
api.b.SetHead(uint64(number.Int64()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublicNetAPI offers network related RPC methods
|
// PublicNetAPI offers network related RPC methods
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue