mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-08 03:51:22 +00:00
Run prune blobs on migrator thread
This commit is contained in:
parent
a875bec5f2
commit
caa04db58a
@ -86,6 +86,7 @@ pub enum PruningError {
|
|||||||
pub enum Notification {
|
pub enum Notification {
|
||||||
Finalization(FinalizationNotification),
|
Finalization(FinalizationNotification),
|
||||||
Reconstruction,
|
Reconstruction,
|
||||||
|
PruneBlobs(Option<Epoch>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FinalizationNotification {
|
pub struct FinalizationNotification {
|
||||||
@ -152,6 +153,14 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn process_prune_blobs(&self, data_availability_boundary: Option<Epoch>) {
|
||||||
|
if let Some(Notification::PruneBlobs(data_availability_boundary)) =
|
||||||
|
self.send_background_notification(Notification::PruneBlobs(data_availability_boundary))
|
||||||
|
{
|
||||||
|
Self::run_prune_blobs(self.db.clone(), data_availability_boundary, &self.log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_reconstruction(db: Arc<HotColdDB<E, Hot, Cold>>, log: &Logger) {
|
pub fn run_reconstruction(db: Arc<HotColdDB<E, Hot, Cold>>, log: &Logger) {
|
||||||
if let Err(e) = db.reconstruct_historic_states() {
|
if let Err(e) = db.reconstruct_historic_states() {
|
||||||
error!(
|
error!(
|
||||||
@ -162,6 +171,20 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_prune_blobs(
|
||||||
|
db: Arc<HotColdDB<E, Hot, Cold>>,
|
||||||
|
data_availability_boundary: Option<Epoch>,
|
||||||
|
log: &Logger,
|
||||||
|
) {
|
||||||
|
if let Err(e) = db.try_prune_blobs(false, data_availability_boundary) {
|
||||||
|
error!(
|
||||||
|
log,
|
||||||
|
"Blobs pruning failed";
|
||||||
|
"error" => ?e,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// If configured to run in the background, send `notif` to the background thread.
|
/// If configured to run in the background, send `notif` to the background thread.
|
||||||
///
|
///
|
||||||
/// Return `None` if the message was sent to the background thread, `Some(notif)` otherwise.
|
/// Return `None` if the message was sent to the background thread, `Some(notif)` otherwise.
|
||||||
@ -320,11 +343,15 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
|
|||||||
best
|
best
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(Notification::Finalization(_), Notification::PruneBlobs(_)) => best,
|
||||||
|
(Notification::PruneBlobs(_), Notification::Finalization(_)) => other,
|
||||||
|
(Notification::PruneBlobs(_), Notification::PruneBlobs(_)) => best,
|
||||||
});
|
});
|
||||||
|
|
||||||
match notif {
|
match notif {
|
||||||
Notification::Reconstruction => Self::run_reconstruction(db.clone(), &log),
|
Notification::Reconstruction => Self::run_reconstruction(db.clone(), &log),
|
||||||
Notification::Finalization(fin) => Self::run_migration(db.clone(), fin, &log),
|
Notification::Finalization(fin) => Self::run_migration(db.clone(), fin, &log),
|
||||||
|
Notification::PruneBlobs(dab) => Self::run_prune_blobs(db.clone(), dab, &log),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user