add final & safe headers to BlockStart

This commit is contained in:
Sina Mahmoodi 2023-07-12 17:22:52 +02:00
parent 0aeec7f1b5
commit b692a68a3b
2 changed files with 8 additions and 4 deletions

View file

@ -160,7 +160,7 @@ type BlockchainLogger interface {
state.StateLogger
// OnBlockStart is called before executing `block`.
// `td` is the total difficulty prior to `block`.
OnBlockStart(block *types.Block, td *big.Int)
OnBlockStart(block *types.Block, td *big.Int, finalized *types.Header, safe *types.Header)
OnBlockEnd(err error)
OnGenesisBlock(genesis *types.Block)
}
@ -1778,7 +1778,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
if bc.logger != nil {
td := bc.GetTd(block.ParentHash(), block.NumberU64()-1)
bc.logger.OnBlockStart(block, td)
bc.logger.OnBlockStart(block, td, bc.CurrentFinalBlock(), bc.CurrentSafeBlock())
}
receipts, logs, usedGas, err := bc.processor.Process(block, statedb, bc.vmConfig)
if err != nil {

View file

@ -70,8 +70,12 @@ func (p *Printer) CaptureTxEnd(receipt *types.Receipt) {
fmt.Printf("CaptureTxEnd: receipt=%s\n", buf)
}
func (p *Printer) OnBlockStart(b *types.Block, td *big.Int) {
fmt.Printf("OnBlockStart: b=%v, td=%v\n", b.NumberU64(), td)
func (p *Printer) OnBlockStart(b *types.Block, td *big.Int, finalized, safe *types.Header) {
if finalized != nil && safe != nil {
fmt.Printf("OnBlockStart: b=%v, td=%v, finalized=%v, safe=%v\n", b.NumberU64(), td, finalized.Number.Uint64(), safe.Number.Uint64())
} else {
fmt.Printf("OnBlockStart: b=%v, td=%v\n", b.NumberU64(), td)
}
}
func (p *Printer) OnBlockEnd(err error) {