From 0b0a1ad32137956a20c73aa044af15a197e65563 Mon Sep 17 00:00:00 2001 From: NathanBSC Date: Mon, 22 Jul 2024 10:16:01 +0800 Subject: [PATCH] core: cache block after wroten into db --- core/blockchain.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index 9e7affa910..d74b5f207b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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() }()