Wrong rpc inflation rate (#14063)
* Fix wrong inflation calculation in rpc * Reorder * Fix test
This commit is contained in:
@ -1511,6 +1511,13 @@ impl Bank {
|
||||
self.epoch_schedule.get_first_slot_in_epoch(self.epoch()) - inflation_start_slot
|
||||
}
|
||||
|
||||
pub fn slot_in_year_for_inflation(&self) -> f64 {
|
||||
let num_slots = self.get_inflation_num_slots();
|
||||
|
||||
// calculated as: num_slots / (slots / year)
|
||||
num_slots as f64 / self.slots_per_year
|
||||
}
|
||||
|
||||
// update rewards based on the previous epoch
|
||||
fn update_rewards(
|
||||
&mut self,
|
||||
@ -1522,10 +1529,7 @@ impl Bank {
|
||||
}
|
||||
// if I'm the first Bank in an epoch, count, claim, disburse rewards from Inflation
|
||||
|
||||
// calculated as: num_slots / (slots / year)
|
||||
let num_slots = self.get_inflation_num_slots();
|
||||
let slot_in_year = num_slots as f64 / self.slots_per_year;
|
||||
|
||||
let slot_in_year = self.slot_in_year_for_inflation();
|
||||
let epoch_duration_in_years = self.epoch_duration_in_years(prev_epoch);
|
||||
|
||||
let (validator_rate, foundation_rate) = {
|
||||
|
Reference in New Issue
Block a user