Add methods to delete blocks and states from disk (#843)

Closes #833
This commit is contained in:
Michael Sproul
2020-03-04 16:48:35 +11:00
committed by GitHub
parent 12d9b42188
commit 1f16d8fe4d
3 changed files with 142 additions and 9 deletions

View File

@@ -91,6 +91,11 @@ pub trait Store<E: EthSpec>: Sync + Send + Sized + 'static {
self.get(block_root)
}
/// Delete a block from the store.
fn delete_block(&self, block_root: &Hash256) -> Result<(), Error> {
self.delete::<SignedBeaconBlock<E>>(block_root)
}
/// Store a state in the store.
fn put_state(&self, state_root: &Hash256, state: BeaconState<E>) -> Result<(), Error>;
@@ -123,6 +128,11 @@ pub trait Store<E: EthSpec>: Sync + Send + Sized + 'static {
self.get_state(state_root, slot)
}
/// Delete a state from the store.
fn delete_state(&self, state_root: &Hash256, _slot: Slot) -> Result<(), Error> {
self.key_delete(DBColumn::BeaconState.into(), state_root.as_bytes())
}
/// (Optionally) Move all data before the frozen slot to the freezer database.
fn freeze_to_state(
_store: Arc<Self>,