mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
fix: correctly initialize latest l1msg gauge (#1155)
This commit is contained in:
parent
c529171c9b
commit
6451c80d55
1 changed files with 16 additions and 9 deletions
|
|
@ -149,6 +149,18 @@ var defaultCacheConfig = &CacheConfig{
|
|||
SnapshotWait: true,
|
||||
}
|
||||
|
||||
func updateHeadL1msgGauge(block *types.Block) {
|
||||
for _, tx := range block.Transactions() {
|
||||
if msg := tx.AsL1MessageTx(); msg != nil {
|
||||
// Queue index is guaranteed to fit into int64.
|
||||
headL1MessageGauge.Update(int64(msg.QueueIndex))
|
||||
} else {
|
||||
// No more L1 messages in this block.
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BlockChain represents the canonical chain given a database with a genesis
|
||||
// block. The Blockchain manages chain imports, reverts, chain reorganisations.
|
||||
//
|
||||
|
|
@ -423,6 +435,9 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
|
|||
triedb.SaveCachePeriodically(bc.cacheConfig.TrieCleanJournal, bc.cacheConfig.TrieCleanRejournal, bc.quit)
|
||||
}()
|
||||
}
|
||||
|
||||
updateHeadL1msgGauge(bc.CurrentBlock())
|
||||
|
||||
return bc, nil
|
||||
}
|
||||
|
||||
|
|
@ -1255,15 +1270,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
|||
}
|
||||
|
||||
// Note the latest relayed L1 message queue index (if any)
|
||||
for _, tx := range block.Transactions() {
|
||||
if msg := tx.AsL1MessageTx(); msg != nil {
|
||||
// Queue index is guaranteed to fit into int64.
|
||||
headL1MessageGauge.Update(int64(msg.QueueIndex))
|
||||
} else {
|
||||
// No more L1 messages in this block.
|
||||
break
|
||||
}
|
||||
}
|
||||
updateHeadL1msgGauge(block)
|
||||
|
||||
parent := bc.GetHeaderByHash(block.ParentHash())
|
||||
// block.Time is guaranteed to be larger than parent.Time,
|
||||
|
|
|
|||
Loading…
Reference in a new issue