[][src]Struct hbbft::binary_agreement::BinaryAgreement

pub struct BinaryAgreement<N, S> { /* fields omitted */ }

Binary Agreement instance

Methods

impl<N: NodeIdT, S: SessionIdT> BinaryAgreement<N, S>[src]

pub fn new(netinfo: Arc<NetworkInfo<N>>, session_id: S) -> Result<Self>[src]

Creates a new BinaryAgreement instance with the given session identifier, to prevent replaying messages in other instances.

pub fn propose(&mut self, input: bool) -> Result<Step<N>>[src]

Proposes a boolean value for Binary Agreement.

If more than two thirds of validators propose the same value, that will eventually be output. Otherwise either output is possible.

Note that if can_propose returns false, it is already too late to affect the outcome.

pub fn handle_message(&mut self, sender_id: &N, msg: Message) -> Result<Step<N>>[src]

Handles a message received from sender_id.

This must be called with every message we receive from another node.

pub fn can_propose(&self) -> bool[src]

Whether we can still input a value. It is not an error to input if this returns false, but it will have no effect on the outcome.

Trait Implementations

impl<N: NodeIdT, S: SessionIdT> ConsensusProtocol for BinaryAgreement<N, S>[src]

type NodeId = N

Unique node identifier.

type Input = bool

The input provided by the user.

type Output = bool

The output type. Some algorithms return an output exactly once, others return multiple times. Read more

type Message = Message

The messages that need to be exchanged between the instances in the participating nodes.

type Error = Error

The errors that can occur during execution.

type FaultKind = FaultKind

The kinds of message faults that can be detected during execution.

fn handle_message<R: Rng>(
    &mut self,
    sender_id: &Self::NodeId,
    message: Message,
    _rng: &mut R
) -> Result<Step<N>>
[src]

Receive input from a remote node.

fn terminated(&self) -> bool[src]

Whether the algorithm has terminated.

impl<N: NodeIdT, S: SessionIdT> Display for BinaryAgreement<N, S>[src]

impl<N: Debug, S: Debug> Debug for BinaryAgreement<N, S>[src]

Auto Trait Implementations

impl<N, S> Send for BinaryAgreement<N, S> where
    N: Send + Sync,
    S: Send

impl<N, S> Sync for BinaryAgreement<N, S> where
    N: Send + Sync,
    S: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.