rename Hook “OnTerminate” to “OnBlockchainTerminate”

This commit is contained in:
Chris Ziogas 2024-04-03 14:07:59 +03:00
parent e67c3bfd62
commit 5ba5254cfb
No known key found for this signature in database
GPG key ID: 2329CF479E36E2DA
3 changed files with 20 additions and 20 deletions

View file

@ -1172,8 +1172,8 @@ func (bc *BlockChain) Stop() {
log.Error("Failed to close trie database", "err", err) log.Error("Failed to close trie database", "err", err)
} }
// Allow tracers to clean-up and release resources. // Allow tracers to clean-up and release resources.
if bc.vmConfig.Tracer != nil && bc.vmConfig.Tracer.OnTerminate != nil { if bc.vmConfig.Tracer != nil && bc.vmConfig.Tracer.OnBlockchainTerminate != nil {
bc.vmConfig.Tracer.OnTerminate() bc.vmConfig.Tracer.OnBlockchainTerminate()
} }
log.Info("Blockchain stopped") log.Info("Blockchain stopped")
} }

View file

@ -107,6 +107,9 @@ type (
// BlockchainInitHook is called when the blockchain is initialized. // BlockchainInitHook is called when the blockchain is initialized.
BlockchainInitHook = func(chainConfig *params.ChainConfig) BlockchainInitHook = func(chainConfig *params.ChainConfig)
// BlockchainTerminateHook is called when the tracer is terminated.
BlockchainTerminateHook = func()
// BlockStartHook is called before executing `block`. // BlockStartHook is called before executing `block`.
// `td` is the total difficulty prior to `block`. // `td` is the total difficulty prior to `block`.
BlockStartHook = func(event BlockEvent) BlockStartHook = func(event BlockEvent)
@ -140,9 +143,6 @@ type (
// LogHook is called when a log is emitted. // LogHook is called when a log is emitted.
LogHook = func(log *types.Log) LogHook = func(log *types.Log)
// TerminateHook is called when the tracer is terminated.
TerminateHook = func()
) )
type Hooks struct { type Hooks struct {
@ -156,6 +156,7 @@ type Hooks struct {
OnGasChange GasChangeHook OnGasChange GasChangeHook
// Chain events // Chain events
OnBlockchainInit BlockchainInitHook OnBlockchainInit BlockchainInitHook
OnBlockchainTerminate BlockchainTerminateHook
OnBlockStart BlockStartHook OnBlockStart BlockStartHook
OnBlockEnd BlockEndHook OnBlockEnd BlockEndHook
OnSkippedBlock SkippedBlockHook OnSkippedBlock SkippedBlockHook
@ -166,7 +167,6 @@ type Hooks struct {
OnCodeChange CodeChangeHook OnCodeChange CodeChangeHook
OnStorageChange StorageChangeHook OnStorageChange StorageChangeHook
OnLog LogHook OnLog LogHook
OnTerminate TerminateHook
} }
// BalanceChangeReason is used to indicate the reason for a balance change, useful // BalanceChangeReason is used to indicate the reason for a balance change, useful

View file

@ -85,7 +85,7 @@ func newSupply(cfg json.RawMessage) (*tracing.Hooks, error) {
OnBalanceChange: t.OnBalanceChange, OnBalanceChange: t.OnBalanceChange,
OnEnter: t.OnEnter, OnEnter: t.OnEnter,
OnExit: t.OnExit, OnExit: t.OnExit,
OnTerminate: t.OnTerminate, OnBlockchainTerminate: t.OnBlockchainTerminate,
}, nil }, nil
} }
@ -230,7 +230,7 @@ func (s *supply) OnExit(depth int, output []byte, gasUsed uint64, err error, rev
s.txCallstack[size-1].calls = append(s.txCallstack[size-1].calls, call) s.txCallstack[size-1].calls = append(s.txCallstack[size-1].calls, call)
} }
func (s *supply) OnTerminate() { func (s *supply) OnBlockchainTerminate() {
if err := s.logger.Close(); err != nil { if err := s.logger.Close(); err != nil {
log.Warn("failed to close supply tracer log file", "error", err) log.Warn("failed to close supply tracer log file", "error", err)
} }