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,
impl<M, O, N, F> Step<M, O, N, F>where
F: Fail,
Sourcepub fn new(
output: Vec<O>,
fault_log: FaultLog<N, F>,
messages: Vec<TargetedMessage<M, N>>,
) -> Self
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.
Sourcepub fn with_output<T: Into<Option<O>>>(self, output: T) -> Self
pub fn with_output<T: Into<Option<O>>>(self, output: T) -> Self
Returns the same step, with the given additional output.
Sourcepub fn map<M2, O2, F2, FO, FF, FM>(
self,
f_out: FO,
f_fail: FF,
f_msg: FM,
) -> Step<M2, O2, N, F2>
pub fn map<M2, O2, F2, FO, FF, FM>( self, f_out: FO, f_fail: FF, f_msg: FM, ) -> Step<M2, O2, N, F2>
Converts self into a step of another type, given conversion methods for output, faults,
and messages.
Sourcepub fn extend_with<M2, O2, F2, FF, FM>(
&mut self,
other: Step<M2, O2, N, F2>,
f_fail: FF,
f_msg: FM,
) -> Vec<O2>
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>
Extends self with others messages and fault logs, and returns other.output.
Source§impl<'i, M, O, N, F> Step<M, O, N, F>
impl<'i, M, O, N, F> Step<M, O, N, F>
Sourcepub fn defer_messages(
&mut self,
peer_epochs: &BTreeMap<N, M::Epoch>,
max_future_epochs: u64,
) -> Vec<(N, M)>
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, O, N, F> From<TargetedMessage<M, N>> for Step<M, O, N, F>where
F: Fail,
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
fn from(msg: TargetedMessage<M, N>) -> Self
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>
impl<M, O, N, F> Sync for Step<M, O, N, F>
impl<M, O, N, F> Unpin for Step<M, O, N, F>
impl<M, O, N, F> UnwindSafe for Step<M, O, N, F>
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> 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