1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use chain_impl_mockchain::{
    block::{ChainLength, HeaderId as HeaderHash},
    fragment::FragmentId,
};
use thiserror::Error;

#[derive(Debug, Error, Clone)]
pub enum ExplorerError {
    #[error(transparent)]
    BlockNotFound(#[from] BlockNotFound),
    #[error("ancestor of block '{0}' not found in explorer")]
    AncestorNotFound(HeaderHash),
    #[error("transaction '{0}' is already indexed")]
    TransactionAlreadyExists(FragmentId),
    #[error("tried to index block '{0}' twice")]
    BlockAlreadyExists(HeaderHash),
    #[error("block with {0} chain length already exists in explorer branch")]
    ChainLengthBlockAlreadyExists(ChainLength),
    #[error("the explorer's database couldn't be initialized: {0}")]
    BootstrapError(String),
    #[error("cannot apply block")]
    CannotApplyBlock,
    #[error("tally decryption failure")]
    TallyDecryptionFailure,
    #[error("tx calculation failure")]
    TxCalculationFailure,
    #[error("unable to transmute to explorer API representation")]
    ExplorerTransmuteFail,
}

#[derive(Debug, Error, Clone)]
#[error("block {hash} not found in explorer")]
pub struct BlockNotFound {
    pub hash: HeaderHash,
}