diff --git a/node/src/types/validator_matrix.rs b/node/src/types/validator_matrix.rs index d9b138a1cc..21fdad24e0 100644 --- a/node/src/types/validator_matrix.rs +++ b/node/src/types/validator_matrix.rs @@ -236,6 +236,20 @@ impl ValidatorMatrix { } } + /// Determine if the active validator is in a current or upcoming set of active validators. + /// + /// This function may produce false positives, as it works backwards from the highest known era. + /// Depending on the current network state, this may be an upcoming or active era, at least the + /// previous era validators may be positively identified by this function. + #[inline] + pub(crate) fn is_active_or_upcoming_validator(&self, public_key: &PublicKey) -> bool { + self.read_inner() + .values() + .rev() + .take(self.auction_delay as usize + 1) + .any(|validator_weights| validator_weights.is_validator(public_key)) + } + /// Returns the public keys of all validators in a given era. /// /// Will return `None` if the era is not known.