feat(stages): checkpoint hashing stages into a new table (#2735)

This commit is contained in:
Alexey Shekhirin
2023-05-22 18:12:46 +04:00
committed by GitHub
parent 1b1ca9e2ca
commit 7273ce8028
4 changed files with 174 additions and 180 deletions

View File

@ -138,6 +138,40 @@ impl StageCheckpoint {
pub fn new(block_number: BlockNumber) -> Self {
Self { block_number, ..Default::default() }
}
/// Returns the account hashing stage checkpoint, if any.
pub fn account_hashing_stage_checkpoint(&self) -> Option<AccountHashingCheckpoint> {
match self.stage_checkpoint {
Some(StageUnitCheckpoint::Account(checkpoint)) => Some(checkpoint),
_ => None,
}
}
/// Returns the storage hashing stage checkpoint, if any.
pub fn storage_hashing_stage_checkpoint(&self) -> Option<StorageHashingCheckpoint> {
match self.stage_checkpoint {
Some(StageUnitCheckpoint::Storage(checkpoint)) => Some(checkpoint),
_ => None,
}
}
/// Sets the stage checkpoint to account hashing.
pub fn with_account_hashing_stage_checkpoint(
mut self,
checkpoint: AccountHashingCheckpoint,
) -> Self {
self.stage_checkpoint = Some(StageUnitCheckpoint::Account(checkpoint));
self
}
/// Sets the stage checkpoint to storage hashing.
pub fn with_storage_hashing_stage_checkpoint(
mut self,
checkpoint: StorageHashingCheckpoint,
) -> Self {
self.stage_checkpoint = Some(StageUnitCheckpoint::Storage(checkpoint));
self
}
}
// TODO(alexey): ideally, we'd want to display block number + stage-specific metric (if available)