dpp/block/finalized_epoch_info/v0/
getters.rs

1use crate::block::finalized_epoch_info::v0::FinalizedEpochInfoV0;
2use crate::fee::Credits;
3use crate::prelude::{BlockHeight, BlockHeightInterval, CoreBlockHeight, TimestampMillis};
4use platform_value::Identifier;
5use std::collections::BTreeMap;
6
7/// Trait for accessing fields of `FinalizedEpochInfoV0`.
8pub trait FinalizedEpochInfoGettersV0 {
9    /// Returns the first block time.
10    fn first_block_time(&self) -> TimestampMillis;
11
12    /// Returns the first block height.
13    fn first_block_height(&self) -> BlockHeight;
14
15    /// Returns the total blocks in the epoch.
16    fn total_blocks_in_epoch(&self) -> BlockHeightInterval;
17
18    /// Returns the first core block height.
19    fn first_core_block_height(&self) -> CoreBlockHeight;
20
21    /// Returns the last core block height.
22    fn next_epoch_start_core_block_height(&self) -> CoreBlockHeight;
23
24    /// Returns the total processing fees.
25    fn total_processing_fees(&self) -> Credits;
26
27    /// Returns the total distributed storage fees.
28    fn total_distributed_storage_fees(&self) -> Credits;
29
30    /// Returns the total created storage fees.
31    fn total_created_storage_fees(&self) -> Credits;
32
33    /// Total rewards given from core subsidy
34    fn core_block_rewards(&self) -> Credits;
35
36    /// Returns a reference to the block proposers map.
37    fn block_proposers(&self) -> &BTreeMap<Identifier, u64>;
38
39    /// Returns the fee multiplier (permille).
40    fn fee_multiplier_permille(&self) -> u64;
41
42    /// Returns the protocol version.
43    fn protocol_version(&self) -> u32;
44}
45
46impl FinalizedEpochInfoGettersV0 for FinalizedEpochInfoV0 {
47    fn first_block_time(&self) -> TimestampMillis {
48        self.first_block_time
49    }
50
51    fn first_block_height(&self) -> BlockHeight {
52        self.first_block_height
53    }
54
55    fn total_blocks_in_epoch(&self) -> BlockHeightInterval {
56        self.total_blocks_in_epoch
57    }
58
59    fn first_core_block_height(&self) -> CoreBlockHeight {
60        self.first_core_block_height
61    }
62
63    fn next_epoch_start_core_block_height(&self) -> CoreBlockHeight {
64        self.next_epoch_start_core_block_height
65    }
66
67    fn total_processing_fees(&self) -> Credits {
68        self.total_processing_fees
69    }
70
71    fn total_distributed_storage_fees(&self) -> Credits {
72        self.total_distributed_storage_fees
73    }
74
75    fn total_created_storage_fees(&self) -> Credits {
76        self.total_created_storage_fees
77    }
78
79    fn core_block_rewards(&self) -> Credits {
80        self.core_block_rewards
81    }
82
83    fn block_proposers(&self) -> &BTreeMap<Identifier, u64> {
84        &self.block_proposers
85    }
86
87    fn fee_multiplier_permille(&self) -> u64 {
88        self.fee_multiplier_permille
89    }
90
91    fn protocol_version(&self) -> u32 {
92        self.protocol_version
93    }
94}