mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 00:43:46 +00:00
feat: add block time metric (#707)
* feat: add block time metric * chore: auto version bump [bot] * trigger ci --------- Co-authored-by: Thegaram <Thegaram@users.noreply.github.com>
This commit is contained in:
parent
62926d4649
commit
0252f85816
2 changed files with 8 additions and 1 deletions
|
|
@ -53,6 +53,7 @@ var (
|
||||||
headBlockGauge = metrics.NewRegisteredGauge("chain/head/block", nil)
|
headBlockGauge = metrics.NewRegisteredGauge("chain/head/block", nil)
|
||||||
headHeaderGauge = metrics.NewRegisteredGauge("chain/head/header", nil)
|
headHeaderGauge = metrics.NewRegisteredGauge("chain/head/header", nil)
|
||||||
headFastBlockGauge = metrics.NewRegisteredGauge("chain/head/receipt", nil)
|
headFastBlockGauge = metrics.NewRegisteredGauge("chain/head/receipt", nil)
|
||||||
|
headTimeGapGauge = metrics.NewRegisteredGauge("chain/head/timegap", nil)
|
||||||
|
|
||||||
l2BaseFeeGauge = metrics.NewRegisteredGauge("chain/fees/l2basefee", nil)
|
l2BaseFeeGauge = metrics.NewRegisteredGauge("chain/fees/l2basefee", nil)
|
||||||
|
|
||||||
|
|
@ -1255,6 +1256,12 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||||
l2BaseFeeGauge.Update(0)
|
l2BaseFeeGauge.Update(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent := bc.GetHeaderByHash(block.ParentHash())
|
||||||
|
// block.Time is guaranteed to be larger than parent.Time,
|
||||||
|
// and the time gap should fit into int64.
|
||||||
|
gap := int64(block.Time() - parent.Time)
|
||||||
|
headTimeGapGauge.Update(gap)
|
||||||
|
|
||||||
// Calculate the total difficulty of the block
|
// Calculate the total difficulty of the block
|
||||||
ptd := bc.GetTd(block.ParentHash(), block.NumberU64()-1)
|
ptd := bc.GetTd(block.ParentHash(), block.NumberU64()-1)
|
||||||
if ptd == nil {
|
if ptd == nil {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 5 // Major version component of the current release
|
VersionMajor = 5 // Major version component of the current release
|
||||||
VersionMinor = 2 // Minor version component of the current release
|
VersionMinor = 2 // Minor version component of the current release
|
||||||
VersionPatch = 5 // Patch version component of the current release
|
VersionPatch = 6 // Patch version component of the current release
|
||||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue