[−][src]Trait rhododendron::Context
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.
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>
&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.
Provided methods
fn on_advance_round(
&self,
accumulator: &Accumulator<Self::Candidate, Self::Digest, Self::AuthorityId, Self::Signature>,
round: u32,
next_round: u32,
reason: AdvanceRoundReason
)
&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
.