mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: state housekeeping after backfill finished (#9870)
This commit is contained in:
@ -90,6 +90,19 @@ pub(crate) struct CanonicalInMemoryStateInner {
|
||||
pub(crate) canon_state_notification_sender: CanonStateNotificationSender,
|
||||
}
|
||||
|
||||
impl CanonicalInMemoryStateInner {
|
||||
/// Clears all entries in the in memory state.
|
||||
fn clear(&self) {
|
||||
let mut blocks = self.in_memory_state.blocks.write();
|
||||
let mut numbers = self.in_memory_state.numbers.write();
|
||||
let mut pending = self.in_memory_state.pending.write();
|
||||
|
||||
blocks.clear();
|
||||
numbers.clear();
|
||||
pending.take();
|
||||
}
|
||||
}
|
||||
|
||||
/// This type is responsible for providing the blocks, receipts, and state for
|
||||
/// all canonical blocks not on disk yet and keeps track of the block range that
|
||||
/// is in memory.
|
||||
@ -144,6 +157,11 @@ impl CanonicalInMemoryState {
|
||||
self.state_by_hash(hash).map(|block| block.block().block.header.clone())
|
||||
}
|
||||
|
||||
/// Clears all entries in the in memory state.
|
||||
pub fn clear_state(&self) {
|
||||
self.inner.clear()
|
||||
}
|
||||
|
||||
/// Updates the pending block with the given block.
|
||||
///
|
||||
/// Note: This assumes that the parent block of the pending block is canonical.
|
||||
|
||||
Reference in New Issue
Block a user