mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
srml: grandpa: Pause/resume current authority set (#3068)
* grandpa: add pause/resume signals to runtime module * grandpa: add tests for srml pause/resume transitions * node: bump spec_version * Apply suggestions from code review * Update core/finality-grandpa/primitives/src/lib.rs * Update core/finality-grandpa/primitives/src/lib.rs
This commit is contained in:
@@ -93,6 +93,14 @@ pub enum ConsensusLog<N: Codec> {
|
||||
/// Note that the authority with given index is disabled until the next change.
|
||||
#[codec(index = "3")]
|
||||
OnDisabled(AuthorityIndex),
|
||||
/// A signal to pause the current authority set after the given delay.
|
||||
/// After finalizing the block at _delay_ the authorities should stop voting.
|
||||
#[codec(index = "4")]
|
||||
Pause(N),
|
||||
/// A signal to resume the current authority set after the given delay.
|
||||
/// After authoring the block at _delay_ the authorities should resume voting.
|
||||
#[codec(index = "5")]
|
||||
Resume(N),
|
||||
}
|
||||
|
||||
impl<N: Codec> ConsensusLog<N> {
|
||||
@@ -100,7 +108,7 @@ impl<N: Codec> ConsensusLog<N> {
|
||||
pub fn try_into_change(self) -> Option<ScheduledChange<N>> {
|
||||
match self {
|
||||
ConsensusLog::ScheduledChange(change) => Some(change),
|
||||
ConsensusLog::ForcedChange(_, _) | ConsensusLog::OnDisabled(_) => None,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +116,23 @@ impl<N: Codec> ConsensusLog<N> {
|
||||
pub fn try_into_forced_change(self) -> Option<(N, ScheduledChange<N>)> {
|
||||
match self {
|
||||
ConsensusLog::ForcedChange(median, change) => Some((median, change)),
|
||||
ConsensusLog::ScheduledChange(_) | ConsensusLog::OnDisabled(_) => None,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Try to cast the log entry as a contained pause signal.
|
||||
pub fn try_into_pause(self) -> Option<N> {
|
||||
match self {
|
||||
ConsensusLog::Pause(delay) => Some(delay),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Try to cast the log entry as a contained resume signal.
|
||||
pub fn try_into_resume(self) -> Option<N> {
|
||||
match self {
|
||||
ConsensusLog::Resume(delay) => Some(delay),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user