MCPcopy Create free account
hub / github.com/base/base / insert

Method insert

crates/execution/flashblocks/src/cache.rs:53–62  ·  view source on GitHub ↗

Inserts a flashblock into the cache. Returns `true` if the flashblock was cached, `false` if it was rejected because its block number exceeds the cache-ahead limit.

(&mut self, flashblock: Flashblock)

Source from the content-addressed store, hash-verified

51 /// Returns `true` if the flashblock was cached, `false` if it was rejected
52 /// because its block number exceeds the cache-ahead limit.
53 pub fn insert(&mut self, flashblock: Flashblock) -> bool {
54 let block_number = flashblock.metadata.block_number;
55 if !self.is_cacheable(block_number) {
56 return false;
57 }
58 let min_block_number_to_retain = block_number.saturating_sub(MAX_CACHE_AHEAD_BLOCKS);
59 self.entries.retain(|&bn, _| bn > min_block_number_to_retain);
60 self.entries.entry(block_number).or_default().insert(flashblock.index, flashblock);
61 true
62 }
63
64 /// Drains all cached flashblocks for the given block number, returning them
65 /// sorted by index. Returns an empty `Vec` when nothing is cached.

Callers 15

apply_flashblockMethod · 0.45
build_pending_stateMethod · 0.45
with_transactionMethod · 0.45
increment_nonceMethod · 0.45
with_receiptMethod · 0.45
with_account_balanceMethod · 0.45
with_execution_timeMethod · 0.45

Calls 2

is_cacheableMethod · 0.80
retainMethod · 0.80

Tested by 2

with_transactionsMethod · 0.36
buildMethod · 0.36