mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +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 {
|
if err := bc.triedb.Close(); err != nil {
|
||||||
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.
|
||||||
|
if bc.logger != nil && bc.logger.OnClose != nil {
|
||||||
|
bc.logger.OnClose()
|
||||||
|
}
|
||||||
log.Info("Blockchain stopped")
|
log.Info("Blockchain stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
|
// CloseHook is called when the blockchain closes.
|
||||||
|
CloseHook = 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)
|
||||||
|
|
@ -153,6 +156,7 @@ type Hooks struct {
|
||||||
OnGasChange GasChangeHook
|
OnGasChange GasChangeHook
|
||||||
// Chain events
|
// Chain events
|
||||||
OnBlockchainInit BlockchainInitHook
|
OnBlockchainInit BlockchainInitHook
|
||||||
|
OnClose CloseHook
|
||||||
OnBlockStart BlockStartHook
|
OnBlockStart BlockStartHook
|
||||||
OnBlockEnd BlockEndHook
|
OnBlockEnd BlockEndHook
|
||||||
OnSkippedBlock SkippedBlockHook
|
OnSkippedBlock SkippedBlockHook
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue