Skip to main content

StewardList

Struct StewardList 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn backup_steward(&self, epoch: u64) -> Option<&[u8]>

Nominal backup steward at index (epoch - election_epoch + 1) % len.

Source

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.

Source

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.

Source

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.

Source

pub fn contains(&self, member_id: &[u8]) -> bool

Source

pub fn members(&self) -> &[Vec<u8>]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn config(&self) -> &StewardListConfig

Source

pub fn election_epoch(&self) -> u64

Source

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

Source§

fn clone(&self) -> StewardList

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StewardList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for StewardList

Source§

fn eq(&self, other: &StewardList) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for StewardList

Source§

impl StructuralPartialEq for StewardList

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Classify for T

Source§

type Classified = T

Source§

fn classify(self) -> T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Declassify for T

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more