mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 22:51:03 +00:00
Revert approval voting (#5438)
* Revert approval-voting subsystem * Approval voting revert encapsulated within 'ops' module * use 'get_stored_blocks' to get lower block height * Fix error message * Optionally shrink/delete stored blocks range * range end number is last block number plus 1 * Apply code review suggestions * Use tristate enum for block range in backend overlay * Add clarification comment * Add comments to private struct
This commit is contained in:
@@ -340,6 +340,19 @@ impl ApprovalVotingSubsystem {
|
||||
metrics,
|
||||
}
|
||||
}
|
||||
|
||||
/// Revert to the block corresponding to the specified `hash`.
|
||||
/// The operation is not allowed for blocks older than the last finalized one.
|
||||
pub fn revert_to(&self, hash: Hash) -> Result<(), SubsystemError> {
|
||||
let config = approval_db::v1::Config { col_data: self.db_config.col_data };
|
||||
let mut backend = approval_db::v1::DbBackend::new(self.db.clone(), config);
|
||||
let mut overlay = OverlayedBackend::new(&backend);
|
||||
|
||||
ops::revert_to(&mut overlay, hash)?;
|
||||
|
||||
let ops = overlay.into_write_ops();
|
||||
backend.write(ops)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Context> overseer::Subsystem<Context, SubsystemError> for ApprovalVotingSubsystem
|
||||
|
||||
Reference in New Issue
Block a user