casper_storage/block_store/
error.rs

1use casper_types::{BlockHash, EraId, TransactionHash};
2use std::fmt::Debug;
3use thiserror::Error;
4
5/// Block store error.
6#[derive(Debug, Error)]
7pub enum BlockStoreError {
8    /// Found a duplicate block entry of the specified height.
9    #[error("duplicate entries for block at height {height}: {first} / {second}")]
10    DuplicateBlock {
11        /// Height at which duplicate was found.
12        height: u64,
13        /// First block hash encountered at `height`.
14        first: BlockHash,
15        /// Second block hash encountered at `height`.
16        second: BlockHash,
17    },
18    /// Found a duplicate switch-block entry of the specified height.
19    #[error("duplicate entries for switch block at era id {era_id}: {first} / {second}")]
20    DuplicateEraId {
21        /// Era ID at which duplicate was found.
22        era_id: EraId,
23        /// First block hash encountered at `era_id`.
24        first: BlockHash,
25        /// Second block hash encountered at `era_id`.
26        second: BlockHash,
27    },
28    /// Found a duplicate transaction entry.
29    #[error("duplicate entries for blocks for transaction {transaction_hash}: {first} / {second}")]
30    DuplicateTransaction {
31        /// Transaction hash at which duplicate was found.
32        transaction_hash: TransactionHash,
33        /// First block hash encountered at `transaction_hash`.
34        first: BlockHash,
35        /// Second block hash encountered at `transaction_hash`.
36        second: BlockHash,
37    },
38    /// Internal error.
39    #[error("internal database error: {0}")]
40    InternalStorage(Box<dyn std::error::Error + Send + Sync>),
41    /// The operation is unsupported.
42    #[error("unsupported operation")]
43    UnsupportedOperation,
44}