Skip to main content

zebra_chain/parameters/network/
error.rs

1//! Error types for `ParametersBuilder`.
2
3use std::path::PathBuf;
4
5use thiserror::Error;
6
7/// An error that can occur when building `Parameters` using `ParametersBuilder`.
8#[derive(Debug, Error, Clone, PartialEq, Eq)]
9pub enum ParametersBuilderError {
10    #[error("cannot use reserved network name '{network_name}' as configured Testnet name, reserved names: {reserved_names:?}")]
11    #[non_exhaustive]
12    ReservedNetworkName {
13        network_name: String,
14        reserved_names: Vec<&'static str>,
15    },
16
17    #[error("network name {network_name} is too long, must be {max_length} characters or less")]
18    #[non_exhaustive]
19    NetworkNameTooLong {
20        network_name: String,
21        max_length: usize,
22    },
23
24    #[error("network name must include only alphanumeric characters or '_'")]
25    #[non_exhaustive]
26    InvalidCharacter,
27
28    #[error("network magic should be distinct from reserved network magics")]
29    #[non_exhaustive]
30    ReservedNetworkMagic,
31
32    #[error("configured genesis hash must parse")]
33    #[non_exhaustive]
34    InvalidGenesisHash,
35
36    #[error(
37        "activation heights on ParametersBuilder must not be set after setting funding streams"
38    )]
39    #[non_exhaustive]
40    LockFundingStreams,
41
42    #[error("activation height must be valid")]
43    #[non_exhaustive]
44    InvalidActivationHeight,
45
46    #[error("Height(0) is reserved for the `Genesis` upgrade")]
47    #[non_exhaustive]
48    InvalidHeightZero,
49
50    #[error("network upgrades must be activated in order specified by the protocol")]
51    #[non_exhaustive]
52    OutOfOrderUpgrades,
53
54    #[error("difficulty limits are valid expanded values")]
55    #[non_exhaustive]
56    InvaildDifficultyLimits,
57
58    #[error("halving interval on ParametersBuilder must not be set after setting funding streams")]
59    #[non_exhaustive]
60    HalvingIntervalAfterFundingStreams,
61
62    #[error("checkpoints file format must be valid")]
63    #[non_exhaustive]
64    InvalidCheckpointsFormat,
65
66    #[error("must parse checkpoints")]
67    #[non_exhaustive]
68    FailedToParseDefaultCheckpoint,
69
70    #[error("could not read file at configured checkpoints file path: {path_buf:?}")]
71    #[non_exhaustive]
72    FailedToReadCheckpointFile { path_buf: PathBuf },
73
74    #[error("could not parse checkpoints at the provided path: {path_buf:?}, err: {err}")]
75    #[non_exhaustive]
76    FailedToParseCheckpointFile { path_buf: PathBuf, err: String },
77
78    #[error("configured checkpoints must be valid")]
79    #[non_exhaustive]
80    InvalidCustomCheckpoints,
81
82    #[error("first checkpoint hash must match genesis hash")]
83    #[non_exhaustive]
84    CheckpointGenesisMismatch,
85
86    #[error(
87        "checkpoints must be provided for block heights below the mandatory checkpoint height"
88    )]
89    #[non_exhaustive]
90    InsufficientCheckpointCoverage,
91}