-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into anca/adr-overall-architecture
- Loading branch information
Showing
18 changed files
with
363 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use core::fmt; | ||
|
||
use malachite_common::{Context, SignedVote, Validator}; | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum Error<Ctx> | ||
where | ||
Ctx: Context, | ||
{ | ||
/// No value to propose | ||
NoValueToPropose, | ||
|
||
/// Proposer not found | ||
ProposerNotFound(Ctx::Address), | ||
|
||
/// Validator not found in validator set | ||
ValidatorNotFound(Ctx::Address), | ||
|
||
/// Invalid vote signature | ||
InvalidVoteSignature(SignedVote<Ctx>, Ctx::Validator), | ||
} | ||
|
||
impl<Ctx> fmt::Display for Error<Ctx> | ||
where | ||
Ctx: Context, | ||
{ | ||
#[cfg_attr(coverage_nightly, coverage(off))] | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Error::NoValueToPropose => write!(f, "No value to propose"), | ||
Error::ProposerNotFound(addr) => write!(f, "Proposer not found: {addr}"), | ||
Error::ValidatorNotFound(addr) => write!(f, "Validator not found: {addr}"), | ||
Error::InvalidVoteSignature(vote, validator) => write!( | ||
f, | ||
"Invalid vote signature by {} on vote {vote:?}", | ||
validator.address() | ||
), | ||
} | ||
} | ||
} | ||
|
||
impl<Ctx> PartialEq for Error<Ctx> | ||
where | ||
Ctx: Context, | ||
{ | ||
#[cfg_attr(coverage_nightly, coverage(off))] | ||
fn eq(&self, other: &Self) -> bool { | ||
match (self, other) { | ||
(Error::NoValueToPropose, Error::NoValueToPropose) => true, | ||
(Error::ProposerNotFound(addr1), Error::ProposerNotFound(addr2)) => addr1 == addr2, | ||
(Error::ValidatorNotFound(addr1), Error::ValidatorNotFound(addr2)) => addr1 == addr2, | ||
( | ||
Error::InvalidVoteSignature(vote1, validator1), | ||
Error::InvalidVoteSignature(vote2, validator2), | ||
) => vote1 == vote2 && validator1 == validator2, | ||
_ => false, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
use malachite_common::{Context, Round, SignedVote, Timeout}; | ||
|
||
use crate::Validity; | ||
|
||
/// Events that can be received by the [`Driver`](crate::Driver). | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub enum Event<Ctx> | ||
where | ||
Ctx: Context, | ||
{ | ||
NewRound(Round), | ||
Proposal(Ctx::Proposal), | ||
Proposal(Ctx::Proposal, Validity), | ||
Vote(SignedVote<Ctx>), | ||
TimeoutElapsed(Timeout), | ||
} |
Oops, something went wrong.