From 13594da0fa129e1a111a1ed1b4a83defaaf2f433 Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Wed, 1 Nov 2023 14:34:02 -0400 Subject: [PATCH] remove unused cache --- eth/core/chain_writer.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/eth/core/chain_writer.go b/eth/core/chain_writer.go index 74657e077..47eedf87f 100644 --- a/eth/core/chain_writer.go +++ b/eth/core/chain_writer.go @@ -109,10 +109,21 @@ func (bc *blockchain) WriteBlockAndSetHead( // to finalize the block. bc.finalizedBlock.Store(block) - // Write the receipts cache. - // TODO deprecate this cache? - if receipts != nil { - bc.receiptsCache.Add(block.Hash(), receipts) + // Store txLookup entries for all transactions in the block. + blockNum := block.NumberU64() + blockHash := block.Hash() + bc.blockNumCache.Add(blockNum, block) + bc.blockHashCache.Add(blockHash, block) + for txIndex, tx := range block.Transactions() { + bc.txLookupCache.Add( + tx.Hash(), + &types.TxLookupEntry{ + Tx: tx, + TxIndex: uint64(txIndex), + BlockNum: blockNum, + BlockHash: blockHash, + }, + ) } // Fire off the feeds.