nil check

This commit is contained in:
Sina Mahmoodi 2023-12-11 15:59:23 +03:30
parent 0484068df5
commit 5e82cbec8d

View file

@ -485,7 +485,9 @@ func (s *StateDB) SelfDestruct(addr common.Address) {
prev: stateObject.selfDestructed,
prevbalance: prev,
})
s.logger.OnBalanceChange(addr, prev, n, BalanceChangeSuicideWithdraw)
if s.logger != nil {
s.logger.OnBalanceChange(addr, prev, n, BalanceChangeSuicideWithdraw)
}
stateObject.markSelfdestructed()
stateObject.data.Balance = n
}
@ -876,7 +878,7 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) {
obj.deleted = true
// If ether was sent to account post-selfdestruct it is burnt.
if bal := obj.Balance(); bal.Sign() != 0 {
if bal := obj.Balance(); bal.Sign() != 0 && s.logger != nil {
s.logger.OnBalanceChange(obj.address, bal, new(big.Int), BalanceChangeBurn)
}
// We need to maintain account deletions explicitly (will remain