Skip to content

Commit

Permalink
added getters for previous and next validator set
Browse files Browse the repository at this point in the history
  • Loading branch information
SmaGMan authored and 0xdeafbeef committed Oct 13, 2024
1 parent 9073272 commit 175019b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/models/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ impl BlockchainConfigParams {
Ok(ok!(self.contains::<ConfigParam36>()) || ok!(self.contains::<ConfigParam37>()))
}

/// Returns the previous validator set.
///
/// Uses [`ConfigParam33`] (temp prev validators) or [`ConfigParam32`] (prev validators).
pub fn get_previous_validator_set(&self) -> Result<Option<ValidatorSet>, Error> {
match ok!(self.get::<ConfigParam33>()) {
None => self.get::<ConfigParam32>(),
set => Ok(set),
}
}

/// Returns the current validator set.
///
/// Uses [`ConfigParam35`] (temp validators) or [`ConfigParam34`] (current validators).
Expand All @@ -432,6 +442,16 @@ impl BlockchainConfigParams {
}
}

/// Returns the next validator set.
///
/// Uses [`ConfigParam37`] (temp next validators) or [`ConfigParam36`] (next validators).
pub fn get_next_validator_set(&self) -> Result<Option<ValidatorSet>, Error> {
match ok!(self.get::<ConfigParam37>()) {
None => self.get::<ConfigParam36>(),
set => Ok(set),
}
}

/// Returns `true` if the config contains a param for the specified id.
pub fn contains<'a, T: KnownConfigParam<'a>>(&'a self) -> Result<bool, Error> {
self.0.contains_key(T::ID)
Expand Down

0 comments on commit 175019b

Please sign in to comment.