mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-17 20:02:43 +00:00
Tracing Integration
- [reference](5bbf1859e9/projects/project-ideas.md (L297))
- [x] replace slog & log with tracing throughout the codebase
- [x] implement custom crit log
- [x] make relevant changes in the formatter
- [x] replace sloggers
- [x] re-write SSE logging components
cc: @macladson @eserilev
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
//! Garbage collection process that runs at start-up to clean up the database.
|
|
use crate::database::interface::BeaconNodeBackend;
|
|
use crate::hot_cold_store::HotColdDB;
|
|
use crate::{DBColumn, Error};
|
|
use tracing::debug;
|
|
use types::EthSpec;
|
|
|
|
impl<E> HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>>
|
|
where
|
|
E: EthSpec,
|
|
{
|
|
/// Clean up the database by performing one-off maintenance at start-up.
|
|
pub fn remove_garbage(&self) -> Result<(), Error> {
|
|
self.delete_temp_states()?;
|
|
Ok(())
|
|
}
|
|
|
|
/// Delete the temporary states that were leftover by failed block imports.
|
|
pub fn delete_temp_states(&self) -> Result<(), Error> {
|
|
let mut ops = vec![];
|
|
self.iter_temporary_state_roots().for_each(|state_root| {
|
|
if let Ok(state_root) = state_root {
|
|
ops.push(state_root);
|
|
}
|
|
});
|
|
if !ops.is_empty() {
|
|
debug!("Garbage collecting {} temporary states", ops.len());
|
|
|
|
self.delete_batch(DBColumn::BeaconState, ops.clone())?;
|
|
self.delete_batch(DBColumn::BeaconStateSummary, ops.clone())?;
|
|
self.delete_batch(DBColumn::BeaconStateTemporary, ops)?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|