mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
core/state: journal WIP 2
This commit is contained in:
parent
1c987949a6
commit
4849f58a7a
3 changed files with 14 additions and 13 deletions
|
|
@ -260,16 +260,16 @@ func (self *StateObject) setBalance(amount *big.Int) {
|
||||||
// Return the gas back to the origin. Used by the Virtual machine or Closures
|
// Return the gas back to the origin. Used by the Virtual machine or Closures
|
||||||
func (c *StateObject) ReturnGas(gas, price *big.Int) {}
|
func (c *StateObject) ReturnGas(gas, price *big.Int) {}
|
||||||
|
|
||||||
func (self *StateObject) Copy(db trie.Database, onDirty func(addr common.Address)) *StateObject {
|
func (self *StateObject) deepCopy(db *StateDB, onDirty func(addr common.Address)) *StateObject {
|
||||||
// stateObject := NewObject(self.address, self.data, onDirty)
|
stateObject := newObject(db, self.address, self.data, onDirty)
|
||||||
// stateObject.trie = self.trie
|
stateObject.trie = self.trie
|
||||||
// stateObject.code = self.code
|
stateObject.code = self.code
|
||||||
// stateObject.dirtyStorage = self.dirtyStorage.Copy()
|
stateObject.dirtyStorage = self.dirtyStorage.Copy()
|
||||||
// stateObject.cachedStorage = self.dirtyStorage.Copy()
|
stateObject.cachedStorage = self.dirtyStorage.Copy()
|
||||||
// stateObject.remove = self.remove
|
stateObject.remove = self.remove
|
||||||
// stateObject.dirtyCode = self.dirtyCode
|
stateObject.dirtyCode = self.dirtyCode
|
||||||
// stateObject.deleted = self.deleted
|
stateObject.deleted = self.deleted
|
||||||
return self
|
return stateObject
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,7 @@ func (self *StateDB) Logs() vm.Logs {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StateDB) AddRefund(gas *big.Int) {
|
func (self *StateDB) AddRefund(gas *big.Int) {
|
||||||
|
self.journal = append(self.journal, refundChange{prev: new(big.Int).Set(self.refund)})
|
||||||
self.refund.Add(self.refund, gas)
|
self.refund.Add(self.refund, gas)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -452,7 +453,7 @@ func (self *StateDB) Copy() *StateDB {
|
||||||
}
|
}
|
||||||
// Copy the dirty states and logs
|
// Copy the dirty states and logs
|
||||||
for addr, _ := range self.stateObjectsDirty {
|
for addr, _ := range self.stateObjectsDirty {
|
||||||
state.stateObjects[addr] = self.stateObjects[addr].Copy(self.db, state.MarkStateObjectDirty)
|
state.stateObjects[addr] = self.stateObjects[addr].deepCopy(state, state.MarkStateObjectDirty)
|
||||||
state.stateObjectsDirty[addr] = struct{}{}
|
state.stateObjectsDirty[addr] = struct{}{}
|
||||||
}
|
}
|
||||||
for hash, logs := range self.logs {
|
for hash, logs := range self.logs {
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,8 @@ func (self *Env) BlockNumber() *big.Int { return big.NewInt(0) }
|
||||||
|
|
||||||
//func (self *Env) PrevHash() []byte { return self.parent }
|
//func (self *Env) PrevHash() []byte { return self.parent }
|
||||||
func (self *Env) Coinbase() common.Address { return common.Address{} }
|
func (self *Env) Coinbase() common.Address { return common.Address{} }
|
||||||
func (self *Env) MakeSnapshot() Database { return nil }
|
func (self *Env) SnapshotDatabase() int { return 0 }
|
||||||
func (self *Env) SetSnapshot(Database) {}
|
func (self *Env) RevertToSnapshot(int) {}
|
||||||
func (self *Env) Time() *big.Int { return big.NewInt(time.Now().Unix()) }
|
func (self *Env) Time() *big.Int { return big.NewInt(time.Now().Unix()) }
|
||||||
func (self *Env) Difficulty() *big.Int { return big.NewInt(0) }
|
func (self *Env) Difficulty() *big.Int { return big.NewInt(0) }
|
||||||
func (self *Env) Db() Database { return nil }
|
func (self *Env) Db() Database { return nil }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue