1use penumbra_sdk_proto::penumbra::core::component::sct::v1 as pb;
2use penumbra_sdk_proto::DomainType;
3use serde::{Deserialize, Serialize};
45#[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.
12pub epoch_duration: u64,
13}
1415impl DomainType for SctParameters {
16type Proto = pb::SctParameters;
17}
1819impl TryFrom<pb::SctParameters> for SctParameters {
20type Error = anyhow::Error;
2122fn try_from(msg: pb::SctParameters) -> anyhow::Result<Self> {
23Ok(SctParameters {
24 epoch_duration: msg.epoch_duration,
25 })
26 }
27}
2829impl From<SctParameters> for pb::SctParameters {
30fn from(params: SctParameters) -> Self {
31 pb::SctParameters {
32 epoch_duration: params.epoch_duration,
33 }
34 }
35}
3637impl Default for SctParameters {
38fn default() -> Self {
39Self {
40// Measured in blocks, assuming a 5s block time
41 // this is about a day worth of blocks.
42epoch_duration: 17280,
43 }
44 }
45}