[−][src]Struct hbbft::Step
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
.
Methods
impl<M, O, N, F> Step<M, O, N, F> where
F: Fail,
[src]
F: Fail,
pub fn new(
output: Vec<O>,
fault_log: FaultLog<N, F>,
messages: Vec<TargetedMessage<M, N>>
) -> Self
[src]
output: Vec<O>,
fault_log: FaultLog<N, F>,
messages: Vec<TargetedMessage<M, N>>
) -> Self
Creates a new Step
from the given collections.
pub fn with_output<T: Into<Option<O>>>(self, output: T) -> Self
[src]
Returns the same step, with the given additional output.
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,
[src]
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.
#[must_use]
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,
[src]
&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 other
s messages and fault logs, and returns other.output
.
pub fn extend(&mut self, other: Self)
[src]
Adds the outputs, fault logs and messages of other
to self
.
pub fn join(self, other: Self) -> Self
[src]
Extends this step with other
and returns the result.
pub fn is_empty(&self) -> bool
[src]
Returns true
if there are no messages, faults or outputs.
impl<'i, M, O, N, F> Step<M, O, N, F> where
N: NodeIdT,
M: 'i + Clone + SenderQueueableMessage,
F: Fail,
[src]
N: NodeIdT,
M: 'i + Clone + SenderQueueableMessage,
F: Fail,
pub fn defer_messages(
&mut self,
peer_epochs: &BTreeMap<N, M::Epoch>,
max_future_epochs: u64
) -> Vec<(N, M)>
[src]
&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
impl<M, O, N, F> Default for Step<M, O, N, F> where
F: Fail,
[src]
F: Fail,
impl<M, O, N, F> From<FaultLog<N, F>> for Step<M, O, N, F> where
F: Fail,
[src]
F: Fail,
impl<M, O, N, F> From<Fault<N, F>> for Step<M, O, N, F> where
F: Fail,
[src]
F: Fail,
impl<M, O, N, F> From<TargetedMessage<M, N>> for Step<M, O, N, F> where
F: Fail,
[src]
F: Fail,
fn from(msg: TargetedMessage<M, N>) -> Self
[src]
impl<I, M, O, N, F> From<I> for Step<M, O, N, F> where
I: IntoIterator<Item = TargetedMessage<M, N>>,
F: Fail,
[src]
I: IntoIterator<Item = TargetedMessage<M, N>>,
F: Fail,
impl<M: Debug, O: Debug, N: Debug, F: Debug + Fail> Debug for Step<M, O, N, F>
[src]
Auto Trait Implementations
impl<M, O, N, F> Send for Step<M, O, N, F> where
M: Send,
N: Send,
O: Send,
M: Send,
N: Send,
O: Send,
impl<M, O, N, F> Sync for Step<M, O, N, F> where
M: Sync,
N: Sync,
O: Sync,
M: Sync,
N: Sync,
O: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,