solana_accounts_db/partitioned_rewards.rs
1//! Code related to partitioned rewards distribution
2
3/// # stake accounts to store in one block during partitioned reward interval
4/// Target to store 64 rewards per entry/tick in a block. A block has a minimum of 64
5/// entries/tick. This gives 4096 total rewards to store in one block.
6/// This constant affects consensus.
7const MAX_PARTITIONED_REWARDS_PER_BLOCK: u64 = 4096;
8
9#[derive(Debug, Clone, Copy)]
10/// Configuration options for partitioned epoch rewards.
11pub struct PartitionedEpochRewardsConfig {
12 /// number of stake accounts to store in one block during partitioned reward interval
13 /// normally, this is a number tuned for reasonable performance, such as 4096 accounts/block
14 pub stake_account_stores_per_block: u64,
15}
16
17/// Convenient constant for default partitioned epoch rewards configuration
18/// used for benchmarks and tests.
19pub const DEFAULT_PARTITIONED_EPOCH_REWARDS_CONFIG: PartitionedEpochRewardsConfig =
20 PartitionedEpochRewardsConfig {
21 stake_account_stores_per_block: MAX_PARTITIONED_REWARDS_PER_BLOCK,
22 };
23
24impl Default for PartitionedEpochRewardsConfig {
25 fn default() -> Self {
26 Self {
27 stake_account_stores_per_block: MAX_PARTITIONED_REWARDS_PER_BLOCK,
28 }
29 }
30}
31
32impl PartitionedEpochRewardsConfig {
33 /// Only for tests and benchmarks
34 pub fn new_for_test(stake_account_stores_per_block: u64) -> Self {
35 Self {
36 stake_account_stores_per_block,
37 }
38 }
39}