From 175019bbae9f93f06402371982365662239d59aa Mon Sep 17 00:00:00 2001 From: Vitaly Date: Fri, 11 Oct 2024 16:19:39 +0000 Subject: [PATCH] added getters for previous and next validator set --- src/models/config/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/models/config/mod.rs b/src/models/config/mod.rs index e8aa6cef..292414ba 100644 --- a/src/models/config/mod.rs +++ b/src/models/config/mod.rs @@ -422,6 +422,16 @@ impl BlockchainConfigParams { Ok(ok!(self.contains::()) || ok!(self.contains::())) } + /// Returns the previous validator set. + /// + /// Uses [`ConfigParam33`] (temp prev validators) or [`ConfigParam32`] (prev validators). + pub fn get_previous_validator_set(&self) -> Result, Error> { + match ok!(self.get::()) { + None => self.get::(), + set => Ok(set), + } + } + /// Returns the current validator set. /// /// Uses [`ConfigParam35`] (temp validators) or [`ConfigParam34`] (current validators). @@ -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, Error> { + match ok!(self.get::()) { + None => self.get::(), + 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 { self.0.contains_key(T::ID)