ccp_shared/types/
epoch_parameters.rs1use serde::Deserialize;
18use serde::Serialize;
19
20use crate::proof::CCProofId;
21use crate::types::Difficulty;
22use crate::types::GlobalNonce;
23
24#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
26#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
27pub struct EpochParameters {
28 pub global_nonce: GlobalNonce,
29 pub difficulty: Difficulty,
30}
31
32impl EpochParameters {
33 pub const fn new(global_nonce: GlobalNonce, difficulty: Difficulty) -> Self {
34 Self {
35 global_nonce,
36 difficulty,
37 }
38 }
39}
40
41impl From<CCProofId> for EpochParameters {
42 fn from(id: CCProofId) -> Self {
43 Self {
44 global_nonce: id.global_nonce,
45 difficulty: id.difficulty,
46 }
47 }
48}
49
50use std::fmt;
51
52impl fmt::Display for EpochParameters {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 writeln!(f, "global nonce: {}", self.global_nonce)?;
55 writeln!(f, "difficulty: {}", self.difficulty)
56 }
57}