partitioned rewards helper functions (#31818)

This commit is contained in:
Jeff Washington (jwash) 2023-05-30 08:57:31 -05:00 committed by GitHub
parent 03b260a29f
commit 0c64e26d53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

View File

@ -62,6 +62,7 @@ use {
epoch_stakes::{EpochStakes, NodeVoteAccounts},
inline_spl_token,
message_processor::MessageProcessor,
partitioned_rewards::PartitionedEpochRewardsConfig,
rent_collector::{CollectedInfo, RentCollector},
rent_debits::RentDebits,
runtime_config::RuntimeConfig,
@ -1437,6 +1438,38 @@ impl Bank {
rent_collector.clone_with_epoch(epoch)
}
#[allow(dead_code)]
pub(crate) fn set_epoch_reward_status_active(&mut self, stake_rewards: StakeRewards) {
self.epoch_reward_status = EpochRewardStatus::Active(StartBlockHeightAndRewards {
start_block_height: self.block_height,
calculated_epoch_stake_rewards: Arc::new(stake_rewards),
});
}
#[allow(dead_code)]
fn partitioned_epoch_rewards_config(&self) -> &PartitionedEpochRewardsConfig {
&self
.rc
.accounts
.accounts_db
.partitioned_epoch_rewards_config
}
/// # stake accounts to store in one block during partitioned reward interval
#[allow(dead_code)]
fn partitioned_rewards_stake_account_stores_per_block(&self) -> u64 {
self.partitioned_epoch_rewards_config()
.stake_account_stores_per_block
}
/// reward calculation happens synchronously during the first block of the epoch boundary.
/// So, # blocks for reward calculation is 1.
#[allow(dead_code)]
fn get_reward_calculation_num_blocks(&self) -> Slot {
self.partitioned_epoch_rewards_config()
.reward_calculation_num_blocks
}
fn _new_from_parent(
parent: &Arc<Bank>,
collector_id: &Pubkey,