Skip to content

Commit

Permalink
Update node/bft/ledger-service/src/ledger.rs
Browse files Browse the repository at this point in the history
Co-authored-by: ljedrz <[email protected]>
  • Loading branch information
vicsn and ljedrz authored Jan 7, 2025
1 parent 970386f commit 975749a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions node/bft/ledger-service/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,13 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for CoreLedgerService<
// Advance to the next block.
self.ledger.advance_to_next_block(block)?;
// Add the block to the block cache.
self.block_cache.write().insert(block.height(), block.clone());
// Prune the block cache if it exceeds the maximum size.
if self.block_cache.read().len() > BLOCK_CACHE_SIZE {
self.block_cache.write().pop_first();
{
let mut block_cache = self.block_cache.write();
block_cache.insert(block.height(), block.clone());
// Prune the block cache if it exceeds the maximum size.
if block_cache.len() > BLOCK_CACHE_SIZE {
block_cache.pop_first();
}
}
// Update BFT metrics.
#[cfg(feature = "metrics")]
Expand Down

0 comments on commit 975749a

Please sign in to comment.