dpp/fee/epoch/
mod.rs

1// MIT LICENSE
2//
3// Copyright (c) 2021 Dash Core Group
4//
5// Permission is hereby granted, free of charge, to any
6// person obtaining a copy of this software and associated
7// documentation files (the "Software"), to deal in the
8// Software without restriction, including without
9// limitation the rights to use, copy, modify, merge,
10// publish, distribute, sublicense, and/or sell copies of
11// the Software, and to permit persons to whom the Software
12// is furnished to do so, subject to the following
13// conditions:
14//
15// The above copyright notice and this permission notice
16// shall be included in all copies or substantial portions
17// of the Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
20// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
21// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
22// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
23// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
26// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27// DEALINGS IN THE SOFTWARE.
28//
29
30//! Epochs
31//!
32//! Fee distribution is based on epochs. One epoch is about 18 days
33//!
34
35use nohash_hasher::IntMap;
36
37#[cfg(feature = "fee-distribution")]
38pub mod distribution;
39
40/// Epoch index type
41use crate::block::epoch::EpochIndex;
42use crate::fee::{Credits, SignedCredits};
43
44/// Genesis epoch index
45pub const GENESIS_EPOCH_INDEX: EpochIndex = 0;
46
47/// Eras of fees charged for perpetual storage
48/// An Era is set to 1 year on Mainnet
49pub const PERPETUAL_STORAGE_ERAS: u16 = 50;
50
51pub const DEFAULT_EPOCHS_PER_ERA: u16 = 40;
52
53pub const fn perpetual_storage_epochs(epochs_per_era: u16) -> u16 {
54    epochs_per_era * PERPETUAL_STORAGE_ERAS
55}
56
57/// Credits per epoch map
58pub type CreditsPerEpoch = IntMap<EpochIndex, Credits>;
59
60/// Bytes removed per epoch map
61pub type BytesPerEpoch = IntMap<EpochIndex, u32>;
62
63/// Signed credits per epoch map
64pub type SignedCreditsPerEpoch = IntMap<EpochIndex, SignedCredits>;