1use crate::base_types::EpochId;
5use crate::message_envelope::Message;
6use crate::messages_checkpoint::{CheckpointDigest, CheckpointSummary, CheckpointTimestamp};
7
8#[derive(Default)]
10pub struct EpochData {
11 epoch_id: EpochId,
12 epoch_start_timestamp: CheckpointTimestamp,
13 epoch_digest: CheckpointDigest,
14}
15
16impl EpochData {
17 pub fn new(
18 epoch_id: EpochId,
19 epoch_start_timestamp: CheckpointTimestamp,
20 epoch_digest: CheckpointDigest,
21 ) -> Self {
22 Self {
23 epoch_id,
24 epoch_start_timestamp,
25 epoch_digest,
26 }
27 }
28
29 pub fn new_genesis(epoch_start_timestamp: CheckpointTimestamp) -> Self {
30 Self {
31 epoch_id: 0,
32 epoch_start_timestamp,
33 epoch_digest: Default::default(),
34 }
35 }
36
37 pub fn new_from_epoch_checkpoint(
38 epoch_id: EpochId,
39 epoch_checkpoint: &CheckpointSummary,
40 ) -> Self {
41 Self {
42 epoch_id,
43 epoch_start_timestamp: epoch_checkpoint.timestamp_ms,
44 epoch_digest: epoch_checkpoint.digest(),
45 }
46 }
47
48 pub fn new_test() -> Self {
49 Default::default()
50 }
51
52 pub fn epoch_id(&self) -> EpochId {
53 self.epoch_id
54 }
55
56 pub fn epoch_start_timestamp(&self) -> CheckpointTimestamp {
57 self.epoch_start_timestamp
58 }
59
60 pub fn epoch_digest(&self) -> CheckpointDigest {
61 self.epoch_digest
62 }
63}