From c57fdd7cefc4e7a9652b26ef89679fa8743e5b6b Mon Sep 17 00:00:00 2001 From: j75689 Date: Wed, 20 Apr 2022 15:27:30 +0800 Subject: [PATCH] fix comments --- core/blockchain.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/blockchain.go b/core/blockchain.go index 3b1c3c96b4..1ca43ec7c8 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -227,7 +227,7 @@ type BlockChain struct { // trusted diff layers diffLayerCache *lru.Cache // Cache for the diffLayers diffLayerRLPCache *lru.Cache // Cache for the rlp encoded diffLayers - diffLayerChanCache *lru.Cache // Cache for + diffLayerChanCache *lru.Cache // Cache for the difflayer channel diffQueue *prque.Prque // A Priority queue to store recent diff layer diffQueueBuffer chan *types.DiffLayer diffLayerFreezerBlockLimit uint64 @@ -1834,6 +1834,9 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. diffLayer.Number = block.NumberU64() diffLayerCh := make(chan struct{}) + if bc.diffLayerChanCache.Len() >= diffLayerCacheLimit { + bc.diffLayerChanCache.RemoveOldest() + } bc.diffLayerChanCache.Add(diffLayer.BlockHash, diffLayerCh) go bc.cacheDiffLayer(diffLayer, false)