Trait paxakos::communicator::Communicator[][src]

pub trait Communicator: Sized + 'static {
    type Node: NodeInfo;
    type RoundNum: RoundNum;
    type CoordNum: CoordNum;
    type LogEntry: LogEntry;
    type Error: Debug + Send + Sync + 'static;
    type SendPrepare: Future<Output = Result<VoteFor<Self>, Self::Error>>;
    type Abstain: Debug + Send + Sync + 'static;
    type SendProposal: Future<Output = Result<AcceptanceFor<Self>, Self::Error>>;
    type Yea: Debug + Send + Sync + 'static;
    type Nay: Debug + Send + Sync + 'static;
    type SendCommit: Future<Output = Result<Committed, Self::Error>>;
    type SendCommitById: Future<Output = Result<Committed, Self::Error>>;
    fn send_prepare<'a>(
        &mut self,
        receivers: &'a [Self::Node],
        round_num: Self::RoundNum,
        coord_num: Self::CoordNum
    ) -> Vec<(&'a Self::Node, Self::SendPrepare)>;
fn send_proposal<'a>(
        &mut self,
        receivers: &'a [Self::Node],
        round_num: Self::RoundNum,
        coord_num: Self::CoordNum,
        log_entry: Arc<Self::LogEntry>
    ) -> Vec<(&'a Self::Node, Self::SendProposal)>;
fn send_commit<'a>(
        &mut self,
        receivers: &'a [Self::Node],
        round_num: Self::RoundNum,
        coord_num: Self::CoordNum,
        log_entry: Arc<Self::LogEntry>
    ) -> Vec<(&'a Self::Node, Self::SendCommit)>;
fn send_commit_by_id<'a>(
        &mut self,
        receivers: &'a [Self::Node],
        round_num: Self::RoundNum,
        coord_num: Self::CoordNum,
        log_entry_id: <Self::LogEntry as LogEntry>::Id
    ) -> Vec<(&'a Self::Node, Self::SendCommitById)>; }
Expand description

Defines how Nodes call others’ RequestHandlers.

The simplest possible implementation directly calls RequestHandler methods, requiring that all nodes live in the same process. This is useful for prototyping and testing. Most other use cases require a different, custom implementation.

Soundness

Implementations must be secure, i.e. prevent forgery and replay attacks. This implicitly means that a restarted node will not see messages intended for its previous run, i.e. delayed messages sent over a connectionless protocol. Failure to shield a node from such messages may cause it to come out of passive participation mode early and lead to inconsistency.

Associated Types

NodeInfo

The round number type.

The coordination number type.

The log entry type.

The communication error type.

Type of future returned from send_prepare.

Information sent along with abstentions.

Type of future returned from send_proposal.

Information sent along with yea votes.

Information sent along with nay votes.

Type of future returned from send_commit.

Type of future returned from send_commit_by_id.

Required methods

Send a prepare message to all receivers.

Implementations should attempt to call each receivers’ [RequestHandler::handle_prepare][crate::RequestHandler:: handle_prepare]. The return value must contain exactly one entry per receiver with a future of handle_prepare’s result.

Send a proposal message to all receivers.

Implementations should attempt to call each receivers’ [RequestHandler::handle_proposal][crate::RequestHandler:: handle_proposal]. The return value must contain exactly one entry per receiver with a future of handle_proposal’s result.

Send a commit message to all receivers.

Implementations should attempt to call each receivers’ [RequestHandler::handle_commit][crate::RequestHandler:: handle_commit]. The return value must contain exactly one entry per receiver with a future of handle_commit’s result.

Send a commit-by-id message to all receivers.

Implementations should attempt to call each receivers’ [RequestHandler::handle_commit_by_id][crate::RequestHandler:: handle_commit_by_id]. The return value must contain exactly one entry per receiver with a future of handle_commit_by_id’s result.

Implementors