pub struct Step<M, O, N, F: Error> {
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: Error,
impl<M, O, N, F> Step<M, O, N, F>where
F: Error,
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: Error,
impl<M, O, N, F> From<TargetedMessage<M, N>> for Step<M, O, N, F>where
F: Error,
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.