core: cache block after wroten into db (#2600)

This commit is contained in:
Nathan 2024-07-22 20:52:07 +08:00 committed by GitHub
parent b844958a96
commit a44b6d8067
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1801,6 +1801,12 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
if err := blockBatch.Write(); err != nil {
log.Crit("Failed to write block into disk", "err", err)
}
bc.hc.tdCache.Add(block.Hash(), externTd)
bc.blockCache.Add(block.Hash(), block)
bc.receiptsCache.Add(block.Hash(), receipts)
if bc.chainConfig.IsCancun(block.Number(), block.Time()) {
bc.sidecarsCache.Add(block.Hash(), block.Sidecars())
}
wg.Done()
}()