mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 21:04:28 +00:00
Iterate expired components from the da_checker (#5895)
* Iterate expired components from the da_checker * Fix rebase
This commit is contained in:
@@ -269,6 +269,26 @@ impl<E: EthSpec> PendingComponents<E> {
|
|||||||
AvailableExecutedBlock::new(available_block, import_data, payload_verification_outcome),
|
AvailableExecutedBlock::new(available_block, import_data, payload_verification_outcome),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the epoch of the block if it is cached, otherwise returns the epoch of the first blob.
|
||||||
|
pub fn epoch(&self) -> Option<Epoch> {
|
||||||
|
self.executed_block
|
||||||
|
.as_ref()
|
||||||
|
.map(|pending_block| pending_block.as_block().epoch())
|
||||||
|
.or_else(|| {
|
||||||
|
for maybe_blob in self.verified_blobs.iter() {
|
||||||
|
if maybe_blob.is_some() {
|
||||||
|
return maybe_blob.as_ref().map(|kzg_verified_blob| {
|
||||||
|
kzg_verified_blob
|
||||||
|
.as_blob()
|
||||||
|
.slot()
|
||||||
|
.epoch(E::slots_per_epoch())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is the main struct for this module. Outside methods should
|
/// This is the main struct for this module. Outside methods should
|
||||||
@@ -475,6 +495,22 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
|
|||||||
pub fn do_maintenance(&self, cutoff_epoch: Epoch) -> Result<(), AvailabilityCheckError> {
|
pub fn do_maintenance(&self, cutoff_epoch: Epoch) -> Result<(), AvailabilityCheckError> {
|
||||||
// clean up any lingering states in the state cache
|
// clean up any lingering states in the state cache
|
||||||
self.state_cache.do_maintenance(cutoff_epoch);
|
self.state_cache.do_maintenance(cutoff_epoch);
|
||||||
|
|
||||||
|
// Collect keys of pending blocks from a previous epoch to cutoff
|
||||||
|
let mut write_lock = self.critical.write();
|
||||||
|
let mut keys_to_remove = vec![];
|
||||||
|
for (key, value) in write_lock.iter() {
|
||||||
|
if let Some(epoch) = value.epoch() {
|
||||||
|
if epoch < cutoff_epoch {
|
||||||
|
keys_to_remove.push(*key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Now remove keys
|
||||||
|
for key in keys_to_remove {
|
||||||
|
write_lock.pop(&key);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user