Step

Struct Step 

Source
pub struct Step<M, O, N, F: Fail> {
    pub output: Vec<O>,
    pub fault_log: FaultLog<N, F>,
    pub messages: Vec<TargetedMessage<M, N>>,
}
Expand description

Single algorithm step outcome.

Each time input (typically in the form of user input or incoming network messages) is provided to an instance of an algorithm, a Step is produced, potentially containing output values, a fault log, and network messages.

Any Step must always be used by the client application; at the very least the resulting messages must be queued.

§Handling unused Steps

In the (rare) case of a Step not being of any interest at all, instead of discarding it through let _ = ... or similar constructs, the implicit assumption should explicitly be checked instead:

assert!(alg.propose(123).expect("Could not propose value").is_empty(),
        "Algorithm will never output anything on first proposal");

If an edge case occurs and outgoing messages are generated as a result, the assert! will catch it, instead of potentially stalling the algorithm.

Fields§

§output: Vec<O>

The algorithm’s output, after consensus has been reached. This is guaranteed to be the same in all nodes.

§fault_log: FaultLog<N, F>

A list of nodes that are not following consensus, together with information about the detected misbehavior.

§messages: Vec<TargetedMessage<M, N>>

A list of messages that must be sent to other nodes. Each entry contains a message and a Target.

Implementations§

Source§

impl<M, O, N, F> Step<M, O, N, F>
where F: Fail,

Source

pub fn new( output: Vec<O>, fault_log: FaultLog<N, F>, messages: Vec<TargetedMessage<M, N>>, ) -> Self

Creates a new Step from the given collections.

Source

pub fn with_output<T: Into<Option<O>>>(self, output: T) -> Self

Returns the same step, with the given additional output.

Source

pub fn map<M2, O2, F2, FO, FF, FM>( self, f_out: FO, f_fail: FF, f_msg: FM, ) -> Step<M2, O2, N, F2>
where F2: Fail, FO: Fn(O) -> O2, FF: Fn(F) -> F2, FM: Fn(M) -> M2,

Converts self into a step of another type, given conversion methods for output, faults, and messages.

Source

pub fn extend_with<M2, O2, F2, FF, FM>( &mut self, other: Step<M2, O2, N, F2>, f_fail: FF, f_msg: FM, ) -> Vec<O2>
where F2: Fail, FF: Fn(F2) -> F, FM: Fn(M2) -> M,

Extends self with others messages and fault logs, and returns other.output.

Source

pub fn extend(&mut self, other: Self)

Adds the outputs, fault logs and messages of other to self.

Source

pub fn join(self, other: Self) -> Self

Extends this step with other and returns the result.

Source

pub fn is_empty(&self) -> bool

Returns true if there are no messages, faults or outputs.

Source§

impl<'i, M, O, N, F> Step<M, O, N, F>
where N: NodeIdT, M: 'i + Clone + SenderQueueableMessage, F: Fail,

Source

pub fn defer_messages( &mut self, peer_epochs: &BTreeMap<N, M::Epoch>, max_future_epochs: u64, ) -> Vec<(N, M)>

Removes and returns any messages that are not yet accepted by remote nodes according to the mapping remote_epochs. This way the returned messages are postponed until later, and the remaining messages can be sent to remote nodes without delay.

Trait Implementations§

Source§

impl<M: Debug, O: Debug, N: Debug, F: Debug + Fail> Debug for Step<M, O, N, F>

Source§

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

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

impl<M, O, N, F> Default for Step<M, O, N, F>
where F: Fail,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<M, O, N, F> From<Fault<N, F>> for Step<M, O, N, F>
where F: Fail,

Source§

fn from(fault: Fault<N, F>) -> Self

Converts to this type from the input type.
Source§

impl<M, O, N, F> From<FaultLog<N, F>> for Step<M, O, N, F>
where F: Fail,

Source§

fn from(fault_log: FaultLog<N, F>) -> Self

Converts to this type from the input type.
Source§

impl<I, M, O, N, F> From<I> for Step<M, O, N, F>
where I: IntoIterator<Item = TargetedMessage<M, N>>, F: Fail,

Source§

fn from(msgs: I) -> Self

Converts to this type from the input type.
Source§

impl<M, O, N, F> From<TargetedMessage<M, N>> for Step<M, O, N, F>
where F: Fail,

Source§

fn from(msg: TargetedMessage<M, N>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<M, O, N, F> Freeze for Step<M, O, N, F>

§

impl<M, O, N, F> RefUnwindSafe for Step<M, O, N, F>

§

impl<M, O, N, F> Send for Step<M, O, N, F>
where O: Send, M: Send, N: Send,

§

impl<M, O, N, F> Sync for Step<M, O, N, F>
where O: Sync, M: Sync, N: Sync,

§

impl<M, O, N, F> Unpin for Step<M, O, N, F>
where O: Unpin, M: Unpin, N: Unpin, F: Unpin,

§

impl<M, O, N, F> UnwindSafe for Step<M, O, N, F>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<M> Message for M
where M: Debug + Send + Sync,