@@ -149,6 +149,18 @@ var defaultCacheConfig = &CacheConfig{
149
149
SnapshotWait : true ,
150
150
}
151
151
152
+ func updateHeadL1msgGauge (block * types.Block ) {
153
+ for _ , tx := range block .Transactions () {
154
+ if msg := tx .AsL1MessageTx (); msg != nil {
155
+ // Queue index is guaranteed to fit into int64.
156
+ headL1MessageGauge .Update (int64 (msg .QueueIndex ))
157
+ } else {
158
+ // No more L1 messages in this block.
159
+ break
160
+ }
161
+ }
162
+ }
163
+
152
164
// BlockChain represents the canonical chain given a database with a genesis
153
165
// block. The Blockchain manages chain imports, reverts, chain reorganisations.
154
166
//
@@ -423,6 +435,9 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
423
435
triedb .SaveCachePeriodically (bc .cacheConfig .TrieCleanJournal , bc .cacheConfig .TrieCleanRejournal , bc .quit )
424
436
}()
425
437
}
438
+
439
+ updateHeadL1msgGauge (bc .CurrentBlock ())
440
+
426
441
return bc , nil
427
442
}
428
443
@@ -1255,15 +1270,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
1255
1270
}
1256
1271
1257
1272
// Note the latest relayed L1 message queue index (if any)
1258
- for _ , tx := range block .Transactions () {
1259
- if msg := tx .AsL1MessageTx (); msg != nil {
1260
- // Queue index is guaranteed to fit into int64.
1261
- headL1MessageGauge .Update (int64 (msg .QueueIndex ))
1262
- } else {
1263
- // No more L1 messages in this block.
1264
- break
1265
- }
1266
- }
1273
+ updateHeadL1msgGauge (block )
1267
1274
1268
1275
parent := bc .GetHeaderByHash (block .ParentHash ())
1269
1276
// block.Time is guaranteed to be larger than parent.Time,
0 commit comments