only emit event for new accounts

This commit is contained in:
Sina Mahmoodi 2023-06-26 17:39:10 +02:00
parent 057bbdac10
commit a7de17ed21
2 changed files with 7 additions and 5 deletions

View file

@ -153,6 +153,8 @@ var defaultCacheConfig = &CacheConfig{
SnapshotWait: true,
}
// BlockchainLogger is used to collect traces during chain processing.
// Please make a copy of the referenced types if you intend to retain them.
type BlockchainLogger interface {
vm.EVMLogger
state.StateLogger

View file

@ -648,6 +648,10 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
newobj = newObject(s, addr, types.StateAccount{})
if prev == nil {
s.journal.append(createObjectChange{account: &addr})
// TODO: add isPrecompile check
if s.logger != nil {
s.logger.OnNewAccount(addr)
}
} else {
// The original account should be marked as destructed and all cached
// account and storage data should be cleared as well. Note, it must
@ -678,11 +682,7 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
prevStorage: storage,
})
}
// TODO: add isPrecompile check
// TODO: should we emit on account reset?
if s.logger != nil {
s.logger.OnNewAccount(addr)
}
s.setStateObject(newobj)
if prev != nil && !prev.deleted {
return newobj, prev