hashgraph_like_consensus/
error.rs1use alloy::primitives::SignatureError;
8
9#[derive(Debug, thiserror::Error)]
11pub enum ConsensusError {
12 #[error("consensus_threshold must be between 0.0 and 1.0")]
14 InvalidConsensusThreshold,
15 #[error("timeout must be greater than 0")]
16 InvalidTimeout,
17 #[error("expected_voters_count must be greater than 0")]
18 InvalidExpectedVotersCount,
19 #[error("max_rounds must be greater than 0")]
20 InvalidMaxRounds,
21
22 #[error("Invalid vote signature")]
24 InvalidVoteSignature,
25 #[error("Empty signature")]
26 EmptySignature,
27 #[error("Duplicate vote")]
28 DuplicateVote,
29 #[error("User already voted")]
30 UserAlreadyVoted,
31 #[error("Vote expired")]
32 VoteExpired,
33 #[error("Empty vote owner")]
34 EmptyVoteOwner,
35 #[error("Invalid vote hash")]
36 InvalidVoteHash,
37 #[error("Empty vote hash")]
38 EmptyVoteHash,
39 #[error("Proposal expired")]
40 ProposalExpired,
41 #[error("Vote proposal_id mismatch: vote belongs to different proposal")]
42 VoteProposalIdMismatch,
43 #[error("Received hash mismatch")]
44 ReceivedHashMismatch,
45 #[error("Parent hash mismatch")]
46 ParentHashMismatch,
47 #[error("Invalid vote timestamp")]
48 InvalidVoteTimestamp,
49 #[error("Vote timestamp is older than creation time")]
50 TimestampOlderThanCreationTime,
51 #[error("Mismatched length: expected {expect}, actual {actual}")]
52 MismatchedLength { expect: usize, actual: usize },
53
54 #[error("Session not active")]
56 SessionNotActive,
57 #[error("Session not found")]
58 SessionNotFound,
59 #[error("Proposal already exist in consensus service")]
60 ProposalAlreadyExist,
61 #[error("Scope not found")]
62 ScopeNotFound,
63
64 #[error("Insufficient votes at timeout")]
66 InsufficientVotesAtTimeout,
67 #[error("Consensus exceeded configured max rounds")]
68 MaxRoundsExceeded,
69 #[error("Consensus not reached")]
70 ConsensusNotReached,
71 #[error("Consensus failed")]
72 ConsensusFailed,
73
74 #[error("Invalid signature: {0}")]
75 InvalidSignature(#[from] SignatureError),
76 #[error("Failed to sign message: {0}")]
77 FailedToSignMessage(#[from] alloy_signer::Error),
78 #[error("Failed to get current time")]
79 FailedToGetCurrentTime(#[from] std::time::SystemTimeError),
80}