[][src]Trait rhododendron::Context

pub trait Context {
    type Error: From<InputStreamConcluded>;
    type Candidate: Debug + Eq + Clone;
    type Digest: Debug + Hash + Eq + Clone;
    type AuthorityId: Debug + Hash + Eq + Clone;
    type Signature: Debug + Eq + Clone;
    type RoundTimeout: Future<Item = (), Error = Self::Error>;
    type CreateProposal: Future<Item = Self::Candidate, Error = Self::Error>;
    type EvaluateProposal: Future<Item = bool, Error = Self::Error>;
    fn local_id(&self) -> Self::AuthorityId;
fn proposal(&self) -> Self::CreateProposal;
fn candidate_digest(&self, candidate: &Self::Candidate) -> Self::Digest;
fn sign_local(
        &self,
        message: Message<Self::Candidate, Self::Digest>
    ) -> LocalizedMessage<Self::Candidate, Self::Digest, Self::AuthorityId, Self::Signature>;
fn round_proposer(&self, round: u32) -> Self::AuthorityId;
fn proposal_valid(
        &self,
        proposal: &Self::Candidate
    ) -> Self::EvaluateProposal;
fn begin_round_timeout(&self, round: u32) -> Self::RoundTimeout; fn on_advance_round(
        &self,
        accumulator: &Accumulator<Self::Candidate, Self::Digest, Self::AuthorityId, Self::Signature>,
        round: u32,
        next_round: u32,
        reason: AdvanceRoundReason
    ) { ... } }

Context necessary for agreement.

Provides necessary types for protocol messages, and functions necessary for a participant to evaluate and create those messages.

Associated Types

type Error: From<InputStreamConcluded>

Errors which can occur from the futures in this context.

type Candidate: Debug + Eq + Clone

Candidate proposed.

type Digest: Debug + Hash + Eq + Clone

Candidate digest.

type AuthorityId: Debug + Hash + Eq + Clone

Authority ID.

type Signature: Debug + Eq + Clone

Signature.

type RoundTimeout: Future<Item = (), Error = Self::Error>

A future that resolves when a round timeout is concluded.

type CreateProposal: Future<Item = Self::Candidate, Error = Self::Error>

A future that resolves when a proposal is ready.

type EvaluateProposal: Future<Item = bool, Error = Self::Error>

A future that resolves when a proposal has been evaluated.

Loading content...

Required methods

fn local_id(&self) -> Self::AuthorityId

Get the local authority ID.

fn proposal(&self) -> Self::CreateProposal

Get the best proposal.

fn candidate_digest(&self, candidate: &Self::Candidate) -> Self::Digest

Get the digest of a candidate.

fn sign_local(
    &self,
    message: Message<Self::Candidate, Self::Digest>
) -> LocalizedMessage<Self::Candidate, Self::Digest, Self::AuthorityId, Self::Signature>

Sign a message using the local authority ID. In the case of a proposal message, it should sign on the hash and the bytes of the proposal.

fn round_proposer(&self, round: u32) -> Self::AuthorityId

Get the proposer for a given round of consensus.

fn proposal_valid(&self, proposal: &Self::Candidate) -> Self::EvaluateProposal

Whether the proposal is valid.

fn begin_round_timeout(&self, round: u32) -> Self::RoundTimeout

Create a round timeout. The context will determine the correct timeout length, and create a future that will resolve when the timeout is concluded.

Loading content...

Provided methods

fn on_advance_round(
    &self,
    accumulator: &Accumulator<Self::Candidate, Self::Digest, Self::AuthorityId, Self::Signature>,
    round: u32,
    next_round: u32,
    reason: AdvanceRoundReason
)

This hook is called when we advance from current round to next_round. proposal is Some if there was one on the current round.

Loading content...

Implementors

Loading content...