core/state: address comments

This commit is contained in:
Gary Rong 2024-08-27 13:54:26 +08:00
parent 542b83ce19
commit 01f050b96e
3 changed files with 5 additions and 8 deletions

View file

@ -63,9 +63,9 @@ func newJournal() *journal {
}
}
// reset clears the journal, after this operation the journal can be used
// as new. It is semantically similar to calling 'newJournal', but the underlying
// slices can be reused.
// reset clears the journal, after this operation the journal can be used anew.
// It is semantically similar to calling 'newJournal', but the underlying slices
// can be reused.
func (j *journal) reset() {
j.entries = j.entries[:0]
j.validRevisions = j.validRevisions[:0]
@ -192,7 +192,7 @@ func (j *journal) balanceChange(addr common.Address, previous *uint256.Int) {
})
}
func (j *journal) codeChange(address common.Address) {
func (j *journal) setCode(address common.Address) {
j.append(codeChange{account: &address})
}

View file

@ -574,7 +574,7 @@ func (s *stateObject) CodeSize() int {
}
func (s *stateObject) SetCode(codeHash common.Hash, code []byte) {
s.db.journal.codeChange(s.address)
s.db.journal.setCode(s.address)
if s.db.logger != nil && s.db.logger.OnCodeChange != nil {
// TODO remove prevcode from this callback
s.db.logger.OnCodeChange(s.address, common.BytesToHash(s.CodeHash()), nil, codeHash, code)

View file

@ -500,9 +500,6 @@ func (s *StateDB) SelfDestruct(addr common.Address) {
// Regardless of whether it is already destructed or not, we do have to
// journal the balance-change, if we set it to zero here.
if !stateObject.Balance().IsZero() {
if s.logger != nil && s.logger.OnBalanceChange != nil {
s.logger.OnBalanceChange(addr, stateObject.Balance().ToBig(), new(big.Int), tracing.BalanceDecreaseSelfdestruct)
}
stateObject.SetBalance(new(uint256.Int), tracing.BalanceDecreaseSelfdestruct)
}
// If it is already marked as self-destructed, we do not need to add it