Skip to content

Commit

Permalink
Re-add is_active_or_upcoming_validator
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-casperlabs committed Apr 11, 2024
1 parent 95e6bec commit c86f697
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions node/src/types/validator_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c86f697

Please sign in to comment.