mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 22:56:43 +00:00
core/state: properly restore suicided accounts
This commit is contained in:
parent
e376b473fd
commit
7c613c0fb8
2 changed files with 16 additions and 12 deletions
|
|
@ -34,7 +34,7 @@ type (
|
|||
account *common.Address
|
||||
}
|
||||
deleteAccountChange struct {
|
||||
account *common.Address
|
||||
object *StateObject
|
||||
}
|
||||
|
||||
// Changes to individual accounts.
|
||||
|
|
@ -65,7 +65,8 @@ type (
|
|||
)
|
||||
|
||||
func (ch deleteAccountChange) undo(s *StateDB) {
|
||||
s.createStateObject(*ch.account)
|
||||
ch.object.remove = false
|
||||
s.SetStateObject(ch.object)
|
||||
}
|
||||
|
||||
func (ch createAccountChange) undo(s *StateDB) {
|
||||
|
|
|
|||
|
|
@ -212,9 +212,11 @@ func (self *StateDB) GetAccount(addr common.Address) vm.Account {
|
|||
func (self *StateDB) GetBalance(addr common.Address) *big.Int {
|
||||
stateObject := self.GetStateObject(addr)
|
||||
if stateObject != nil {
|
||||
if stateObject.remove {
|
||||
return new(big.Int)
|
||||
}
|
||||
return stateObject.Balance()
|
||||
}
|
||||
|
||||
return common.Big0
|
||||
}
|
||||
|
||||
|
|
@ -318,20 +320,21 @@ func (self *StateDB) SetState(addr common.Address, key common.Hash, value common
|
|||
}
|
||||
|
||||
func (self *StateDB) Delete(addr common.Address) bool {
|
||||
self.journal = append(self.journal, deleteAccountChange{account: &addr})
|
||||
return self.delete(addr)
|
||||
}
|
||||
|
||||
func (self *StateDB) delete(addr common.Address) bool {
|
||||
stateObject := self.GetStateObject(addr)
|
||||
if stateObject != nil {
|
||||
stateObject.markForDeletion()
|
||||
stateObject.data.Balance = new(big.Int)
|
||||
if object := self.delete(addr); object != nil {
|
||||
self.journal = append(self.journal, deleteAccountChange{object: object})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *StateDB) delete(addr common.Address) *StateObject {
|
||||
stateObject := self.GetStateObject(addr)
|
||||
if stateObject != nil {
|
||||
stateObject.markForDeletion()
|
||||
}
|
||||
return stateObject
|
||||
}
|
||||
|
||||
//
|
||||
// Setting, updating & deleting state object methods
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in a new issue