mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
core/exex: exposed last finalized block on chain interface too
This commit is contained in:
parent
062209fff8
commit
e0b4a396f7
2 changed files with 14 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ import (
|
|||
// rather it's a dynamic cast to break cross-package dependencies.
|
||||
type gethChain interface {
|
||||
CurrentBlock() *types.Header
|
||||
CurrentFinalBlock() *types.Header
|
||||
GetHeaderByNumber(number uint64) *types.Header
|
||||
GetBlockByNumber(number uint64) *types.Block
|
||||
StateAt(root common.Hash) (*state.StateDB, error)
|
||||
|
|
@ -54,6 +55,14 @@ func (a *chainAdapter) Head() *types.Header {
|
|||
return types.CopyHeader(a.chain.CurrentBlock())
|
||||
}
|
||||
|
||||
// Final retrieves the last finalized block from the chain. If no finality
|
||||
// is known yet (not synced, not past merge, etc.) or Geth crashed and is
|
||||
// recovering, the returns header will be nil.
|
||||
func (a *chainAdapter) Final() *types.Header {
|
||||
// Headers have public fields, copy to prevent modification
|
||||
return types.CopyHeader(a.chain.CurrentFinalBlock())
|
||||
}
|
||||
|
||||
// Header retrieves a block header with the given number from the canonical
|
||||
// chain. Headers on side-chains are not exposed by the Chain interface.
|
||||
func (a *chainAdapter) Header(number uint64) *types.Header {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ type Chain interface {
|
|||
// Head retrieves the current head block's header from the canonical chain.
|
||||
Head() *types.Header
|
||||
|
||||
// Final retrieves the last finalized block from the chain. If no finality
|
||||
// is known yet (not synced, not past merge, etc.) or Geth crashed and is
|
||||
// recovering, the returns header will be nil.
|
||||
Final() *types.Header
|
||||
|
||||
// Header retrieves a block header with the given number from the canonical
|
||||
// chain. Headers on side-chains are not exposed by the Chain interface.
|
||||
Header(number uint64) *types.Header
|
||||
|
|
|
|||
Loading…
Reference in a new issue