pub struct StewardList { /* private fields */ }Expand description
An ordered list of steward identities for a range of epochs.
Generated deterministically so all conversation members arrive at the same list.
The list covers epochs [election_epoch, election_epoch + len).
Implementations§
Source§impl StewardList
impl StewardList
Sourcepub fn generate(
election_epoch: u64,
conversation_id: &[u8],
member_ids: &[Vec<u8>],
sn: usize,
config: StewardListConfig,
retry_round: u32,
) -> Result<Self, CoreError>
pub fn generate( election_epoch: u64, conversation_id: &[u8], member_ids: &[Vec<u8>], sn: usize, config: StewardListConfig, retry_round: u32, ) -> Result<Self, CoreError>
Generate the deterministic steward list. Sorts candidates by
SHA256(epoch || retry_round || member_id || conversation_id) and takes
the first sn. Errors on empty member_ids or sn outside the
config bounds.
Sourcepub fn validate(
proposed: &[Vec<u8>],
election_epoch: u64,
conversation_id: &[u8],
member_ids: &[Vec<u8>],
config: &StewardListConfig,
retry_round: u32,
) -> Result<bool, CoreError>
pub fn validate( proposed: &[Vec<u8>], election_epoch: u64, conversation_id: &[u8], member_ids: &[Vec<u8>], config: &StewardListConfig, retry_round: u32, ) -> Result<bool, CoreError>
True iff proposed equals what Self::generate would produce
for the same parameters. Compares in place — does not allocate a
full StewardList.
Sourcepub fn epoch_steward(&self, epoch: u64) -> Option<&[u8]>
pub fn epoch_steward(&self, epoch: u64) -> Option<&[u8]>
Nominal epoch steward at index (epoch - election_epoch) % len.
Use Self::live_steward_from with the eligibility predicate to
skip stewards no longer in the conversation.
Sourcepub fn backup_steward(&self, epoch: u64) -> Option<&[u8]>
pub fn backup_steward(&self, epoch: u64) -> Option<&[u8]>
Nominal backup steward at index (epoch - election_epoch + 1) % len.
Sourcepub fn live_epoch_and_backup<F: Fn(&[u8]) -> bool>(
&self,
epoch: u64,
eligible: F,
) -> (Option<&[u8]>, Option<&[u8]>)
pub fn live_epoch_and_backup<F: Fn(&[u8]) -> bool>( &self, epoch: u64, eligible: F, ) -> (Option<&[u8]>, Option<&[u8]>)
Live epoch steward + a distinct backup. Resolving them together
stops the epoch-steward walk from landing on the nominal backup
and collapsing both roles onto the same identity. Backup is
None when fewer than two stewards are eligible.
Sourcepub fn live_steward_from<F: Fn(&[u8]) -> bool>(
&self,
epoch: u64,
offset: usize,
eligible: F,
) -> Option<&[u8]>
pub fn live_steward_from<F: Fn(&[u8]) -> bool>( &self, epoch: u64, offset: usize, eligible: F, ) -> Option<&[u8]>
Walk the rotation starting at offset past eligible == false
and return the first eligible steward. offset = 0 resolves the
epoch steward; offset = 1 resolves the backup. Returns None
when the list is exhausted at epoch or no candidate is eligible.
Sourcepub fn is_exhausted(&self, epoch: u64) -> bool
pub fn is_exhausted(&self, epoch: u64) -> bool
true once every steward has served — the list covers
[election_epoch, election_epoch + len). A new election MUST follow.
pub fn contains(&self, member_id: &[u8]) -> bool
pub fn members(&self) -> &[Vec<u8>]
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn config(&self) -> &StewardListConfig
pub fn election_epoch(&self) -> u64
Sourcepub fn retry_round(&self) -> u32
pub fn retry_round(&self) -> u32
Historical tag — the retry-round seed that was fed into the
SHA256 sort when this list was accepted. Joiners carry this
value in ConversationSync so they can re-derive the same ordering.
Trait Implementations§
Source§impl Clone for StewardList
impl Clone for StewardList
Source§fn clone(&self) -> StewardList
fn clone(&self) -> StewardList
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StewardList
impl Debug for StewardList
Source§impl PartialEq for StewardList
impl PartialEq for StewardList
Source§fn eq(&self, other: &StewardList) -> bool
fn eq(&self, other: &StewardList) -> bool
self and other values to be equal, and is used by ==.impl Eq for StewardList
impl StructuralPartialEq for StewardList
Auto Trait Implementations§
impl Freeze for StewardList
impl RefUnwindSafe for StewardList
impl Send for StewardList
impl Sync for StewardList
impl Unpin for StewardList
impl UnsafeUnpin for StewardList
impl UnwindSafe for StewardList
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more