Improve Rpc inflation tooling (bp #10309) (#10322)

automerge
This commit is contained in:
mergify[bot]
2020-05-29 14:09:41 -07:00
committed by GitHub
parent 37c182cd5d
commit 163217815b
11 changed files with 217 additions and 58 deletions

View File

@@ -16,26 +16,28 @@ use log::*;
use solana_runtime::bank::{Bank, EnteredEpochCallback};
pub fn get_inflation(operating_mode: OperatingMode, epoch: Epoch) -> Option<Inflation> {
let past_epoch_inflation = get_inflation_for_epoch(operating_mode, epoch.saturating_sub(1));
let epoch_inflation = get_inflation_for_epoch(operating_mode, epoch);
if epoch_inflation != past_epoch_inflation || epoch == 0 {
Some(epoch_inflation)
} else {
None
}
}
pub fn get_inflation_for_epoch(operating_mode: OperatingMode, epoch: Epoch) -> Inflation {
match operating_mode {
OperatingMode::Development => {
if epoch == 0 {
Some(Inflation::default())
} else {
None
}
}
OperatingMode::Development => Inflation::default(),
OperatingMode::Stable | OperatingMode::Preview => {
if epoch == 0 {
// No inflation at epoch 0
Some(Inflation::new_disabled())
} else if epoch == std::u64::MAX {
if epoch == std::u64::MAX {
// Inflation starts
//
// The epoch of std::u64::MAX - 1 is a placeholder and is expected to be reduced in
// The epoch of std::u64::MAX is a placeholder and is expected to be reduced in
// a future hard fork.
Some(Inflation::default())
Inflation::default()
} else {
None
// No inflation from epoch 0
Inflation::new_disabled()
}
}
}