mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
add OnClose Hook which triggered on blockchain Stop
This commit is contained in:
parent
256d4b099c
commit
1e84d87a45
2 changed files with 8 additions and 0 deletions
|
|
@ -1157,6 +1157,10 @@ func (bc *BlockChain) Stop() {
|
|||
if err := bc.triedb.Close(); err != nil {
|
||||
log.Error("Failed to close trie database", "err", err)
|
||||
}
|
||||
// Allow tracers to clean-up and release resources.
|
||||
if bc.logger != nil && bc.logger.OnClose != nil {
|
||||
bc.logger.OnClose()
|
||||
}
|
||||
log.Info("Blockchain stopped")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,9 @@ type (
|
|||
// BlockchainInitHook is called when the blockchain is initialized.
|
||||
BlockchainInitHook = func(chainConfig *params.ChainConfig)
|
||||
|
||||
// CloseHook is called when the blockchain closes.
|
||||
CloseHook = func()
|
||||
|
||||
// BlockStartHook is called before executing `block`.
|
||||
// `td` is the total difficulty prior to `block`.
|
||||
BlockStartHook = func(event BlockEvent)
|
||||
|
|
@ -153,6 +156,7 @@ type Hooks struct {
|
|||
OnGasChange GasChangeHook
|
||||
// Chain events
|
||||
OnBlockchainInit BlockchainInitHook
|
||||
OnClose CloseHook
|
||||
OnBlockStart BlockStartHook
|
||||
OnBlockEnd BlockEndHook
|
||||
OnSkippedBlock SkippedBlockHook
|
||||
|
|
|
|||
Loading…
Reference in a new issue