diff --git a/core/blockchain.go b/core/blockchain.go index 05ebfd18b8..ee801972f8 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2375,6 +2375,10 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { if len(rebirthLogs) > 0 { bc.logsFeed.Send(rebirthLogs) } + + if bc.logger != nil && bc.logger.OnReorg != nil { + bc.logger.OnReorg(oldChain) + } return nil } diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index 9019724a8c..1a2b0c86a1 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -134,6 +134,9 @@ type ( // GenesisBlockHook is called when the genesis block is being processed. GenesisBlockHook = func(genesis *types.Block, alloc types.GenesisAlloc) + // ReorgHook is called when a segment of the chain is reverted. + ReorgHook = func(reverted []*types.Block) + // OnSystemCallStartHook is called when a system call is about to be executed. Today, // this hook is invoked when the EIP-4788 system call is about to be executed to set the // beacon block root. @@ -186,6 +189,7 @@ type Hooks struct { OnBlockEnd BlockEndHook OnSkippedBlock SkippedBlockHook OnGenesisBlock GenesisBlockHook + OnReorg ReorgHook OnSystemCallStart OnSystemCallStartHook OnSystemCallEnd OnSystemCallEndHook // State events