penumbra_distributions/
params.rs

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
36
37
38
39
40
41
42
use penumbra_proto::core::component::distributions::v1 as pb;
use penumbra_proto::DomainType;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(
    try_from = "pb::DistributionsParameters",
    into = "pb::DistributionsParameters"
)]
pub struct DistributionsParameters {
    pub staking_issuance_per_block: u64,
}

impl DomainType for DistributionsParameters {
    type Proto = pb::DistributionsParameters;
}

impl TryFrom<pb::DistributionsParameters> for DistributionsParameters {
    type Error = anyhow::Error;

    fn try_from(msg: pb::DistributionsParameters) -> anyhow::Result<Self> {
        Ok(DistributionsParameters {
            staking_issuance_per_block: msg.staking_issuance_per_block,
        })
    }
}

impl From<DistributionsParameters> for pb::DistributionsParameters {
    fn from(params: DistributionsParameters) -> Self {
        pb::DistributionsParameters {
            staking_issuance_per_block: params.staking_issuance_per_block,
        }
    }
}

impl Default for DistributionsParameters {
    fn default() -> Self {
        Self {
            staking_issuance_per_block: 1_000_000,
        }
    }
}