mirror of
https://github.com/vacp2p/hashgraph-like-consensus.git
synced 2026-08-27 13:01:09 +00:00
* feat!: take current time as a caller-supplied parameter * docs(scope): note any key type works as a scope * chore: release 0.6.0 * refactor(tests): share duplicated helpers via tests/common * chore: bump version to 0.6.0 * refactor(readme): adjust syntax
75 lines
2.3 KiB
Rust
75 lines
2.3 KiB
Rust
//! Error types for the consensus library.
|
|
//!
|
|
//! All fallible operations return [`ConsensusError`]. Variants are grouped into
|
|
//! configuration validation, vote/proposal validation, session state, and
|
|
//! consensus result categories.
|
|
|
|
use crate::signing::ConsensusSchemeError;
|
|
|
|
/// Enumerates everything that can go wrong during consensus operations.
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum ConsensusError {
|
|
// Configuration Validation Errors
|
|
#[error("consensus_threshold must be between 0.0 and 1.0")]
|
|
InvalidConsensusThreshold,
|
|
#[error("timeout must be greater than 0")]
|
|
InvalidTimeout,
|
|
#[error("expected_voters_count must be greater than 0")]
|
|
InvalidExpectedVotersCount,
|
|
#[error("max_rounds must be greater than 0")]
|
|
InvalidMaxRounds,
|
|
|
|
// Vote and Proposal Validation Errors
|
|
#[error("Invalid vote signature")]
|
|
InvalidVoteSignature,
|
|
#[error("Empty signature")]
|
|
EmptySignature,
|
|
#[error("Duplicate vote")]
|
|
DuplicateVote,
|
|
#[error("User already voted")]
|
|
UserAlreadyVoted,
|
|
#[error("Vote expired")]
|
|
VoteExpired,
|
|
#[error("Empty vote owner")]
|
|
EmptyVoteOwner,
|
|
#[error("Invalid vote hash")]
|
|
InvalidVoteHash,
|
|
#[error("Empty vote hash")]
|
|
EmptyVoteHash,
|
|
#[error("Proposal expired")]
|
|
ProposalExpired,
|
|
#[error("Vote proposal_id mismatch: vote belongs to different proposal")]
|
|
VoteProposalIdMismatch,
|
|
#[error("Received hash mismatch")]
|
|
ReceivedHashMismatch,
|
|
#[error("Parent hash mismatch")]
|
|
ParentHashMismatch,
|
|
#[error("Invalid vote timestamp")]
|
|
InvalidVoteTimestamp,
|
|
#[error("Vote timestamp is older than creation time")]
|
|
TimestampOlderThanCreationTime,
|
|
|
|
// Session/State Errors
|
|
#[error("Session not active")]
|
|
SessionNotActive,
|
|
#[error("Session not found")]
|
|
SessionNotFound,
|
|
#[error("Proposal already exist in consensus service")]
|
|
ProposalAlreadyExist,
|
|
#[error("Scope not found")]
|
|
ScopeNotFound,
|
|
|
|
// Consensus Result Errors
|
|
#[error("Insufficient votes at timeout")]
|
|
InsufficientVotesAtTimeout,
|
|
#[error("Consensus exceeded configured max rounds")]
|
|
MaxRoundsExceeded,
|
|
#[error("Consensus not reached")]
|
|
ConsensusNotReached,
|
|
#[error("Consensus failed")]
|
|
ConsensusFailed,
|
|
|
|
#[error("Signature scheme failure: {0}")]
|
|
SignatureScheme(#[from] ConsensusSchemeError),
|
|
}
|