Added back OnNewAccount which is Firehose concept so I left it out of the merge commit just before this one

This commit is contained in:
Matthieu Vachon 2024-03-13 16:24:14 -04:00
parent f47d2fc315
commit 7b77261b7c
3 changed files with 11 additions and 0 deletions

View file

@ -635,6 +635,9 @@ func (s *StateDB) getOrNewStateObject(addr common.Address) *stateObject {
func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) {
prev = s.getDeletedStateObject(addr) // Note, prev might have been deleted, we need that!
newobj = newObject(s, addr, nil)
if s.logger != nil && s.logger.OnNewAccount != nil {
s.logger.OnNewAccount(addr, prev != nil)
}
if prev == nil {
s.journal.append(createObjectChange{account: &addr})
} else {

View file

@ -163,6 +163,13 @@ type Hooks struct {
OnCodeChange CodeChangeHook
OnStorageChange StorageChangeHook
OnLog LogHook
// Firehose backward compatibility
// This hook exist because some current Firehose supported chains requires it
// but this field is going to be deprecated and newer chains will not produced
// those events anymore. The hook is registered conditionally based on the
// tracer configuration.
OnNewAccount func(address common.Address, previousExisted bool)
}
// BalanceChangeReason is used to indicate the reason for a balance change, useful

View file

@ -80,6 +80,7 @@ func newFirehoseTracer(cfg json.RawMessage) (*tracing.Hooks, error) {
OnStorageChange: tracer.OnStorageChange,
OnGasChange: tracer.OnGasChange,
OnLog: tracer.OnLog,
OnNewAccount: tracer.OnNewAccount,
}, nil
}