penumbra_sdk_sct/
params.rs

1use penumbra_sdk_proto::penumbra::core::component::sct::v1 as pb;
2use penumbra_sdk_proto::DomainType;
3use serde::{Deserialize, Serialize};
4
5#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
6#[serde(try_from = "pb::SctParameters", into = "pb::SctParameters")]
7/// The configuration parameters for the SCT component.
8pub struct SctParameters {
9    /// The "default" duration of an epoch in number of blocks.
10    /// Note that this is a soft target, and a variety of events
11    /// can trigger an epoch transition.
12    pub epoch_duration: u64,
13}
14
15impl DomainType for SctParameters {
16    type Proto = pb::SctParameters;
17}
18
19impl TryFrom<pb::SctParameters> for SctParameters {
20    type Error = anyhow::Error;
21
22    fn try_from(msg: pb::SctParameters) -> anyhow::Result<Self> {
23        Ok(SctParameters {
24            epoch_duration: msg.epoch_duration,
25        })
26    }
27}
28
29impl From<SctParameters> for pb::SctParameters {
30    fn from(params: SctParameters) -> Self {
31        pb::SctParameters {
32            epoch_duration: params.epoch_duration,
33        }
34    }
35}
36
37impl Default for SctParameters {
38    fn default() -> Self {
39        Self {
40            // Measured in blocks, assuming a 5s block time
41            // this is about a day worth of blocks.
42            epoch_duration: 17280,
43        }
44    }
45}