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

Method drain

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

Drains all cached flashblocks for the given block number, returning them sorted by index. Returns an empty `Vec` when nothing is cached.

(&mut self, block_number: BlockNumber)

Source from the content-addressed store, hash-verified

64 /// Drains all cached flashblocks for the given block number, returning them
65 /// sorted by index. Returns an empty `Vec` when nothing is cached.
66 pub fn drain(&mut self, block_number: BlockNumber) -> Vec<Flashblock> {
67 let Some(by_index) = self.entries.remove(&block_number) else {
68 return Vec::new();
69 };
70 let mut flashblocks: Vec<Flashblock> = by_index.into_values().collect();
71 flashblocks.sort_by_key(|fb| fb.index);
72 flashblocks
73 }
74
75 /// Updates the latest canonical block number and evicts any cached entries
76 /// at or below it (they can no longer be useful).

Callers 6

startMethod · 0.45
insert_and_drainFunction · 0.45
drain_emptyFunction · 0.45
flush_bufferMethod · 0.45

Calls 1

removeMethod · 0.45

Tested by 4

insert_and_drainFunction · 0.36
drain_emptyFunction · 0.36