dubp_common/currency_params/
genesis_block_params.rs

1//  Copyright (C) 2020  Éloïs SANCHEZ.
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Affero General Public License as
5// published by the Free Software Foundation, either version 3 of the
6// License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11// GNU Affero General Public License for more details.
12//
13// You should have received a copy of the GNU Affero General Public License
14// along with this program.  If not, see <https://www.gnu.org/licenses/>.
15
16//! Duniter protocol currency parameters in genesis block
17
18mod v10;
19
20pub use v10::BlockV10Parameters;
21
22use crate::*;
23
24#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
25/// Currency parameters in genesis block
26pub enum GenesisBlockParams {
27    /// Currency parameters in genesis block v10
28    V10(BlockV10Parameters),
29}
30
31impl Default for GenesisBlockParams {
32    fn default() -> Self {
33        GenesisBlockParams::V10(BlockV10Parameters::default())
34    }
35}
36
37#[derive(Debug, Clone, Error)]
38/// Store error in block parameters parsing
39pub enum ParseParamsError {
40    /// ParseIntError
41    #[error("Fail to parse params : {0}")]
42    ParseIntError(std::num::ParseIntError),
43    /// ParseFloatError
44    #[error("Fail to parse params : {0}")]
45    ParseFloatError(std::num::ParseFloatError),
46}
47
48impl From<std::num::ParseIntError> for ParseParamsError {
49    fn from(err: std::num::ParseIntError) -> ParseParamsError {
50        ParseParamsError::ParseIntError(err)
51    }
52}
53
54impl From<std::num::ParseFloatError> for ParseParamsError {
55    fn from(err: std::num::ParseFloatError) -> ParseParamsError {
56        ParseParamsError::ParseFloatError(err)
57    }
58}