move StakeReward to stake_rewards.rs (#32014)

This commit is contained in:
Jeff Washington (jwash) 2023-06-07 14:35:28 -05:00 committed by GitHub
parent c87ff8780a
commit 36ccc71220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 14 deletions

View File

@ -70,6 +70,7 @@ use {
sorted_storages::SortedStorages,
stake_account::{self, StakeAccount},
stake_history::StakeHistory,
stake_rewards::StakeReward,
stake_weighted_timestamp::{
calculate_stake_weighted_timestamp, MaxAllowableDrift,
MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST, MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW_V2,
@ -1129,19 +1130,6 @@ pub struct CommitTransactionCounts {
pub signature_count: u64,
}
#[derive(AbiExample, Debug, Serialize, Deserialize, Clone, PartialEq)]
pub(crate) struct StakeReward {
stake_pubkey: Pubkey,
stake_reward_info: RewardInfo,
stake_account: AccountSharedData,
}
impl StakeReward {
fn get_stake_reward(&self) -> i64 {
self.stake_reward_info.lamports
}
}
/// allow [StakeReward] to be passed to `StoreAccounts` directly without copies or vec construction
impl<'a> StorableAccounts<'a, AccountSharedData> for (Slot, &'a [StakeReward], IncludeSlotInHash) {
fn pubkey(&self, index: usize) -> &Pubkey {

View File

@ -71,6 +71,7 @@ pub mod snapshot_utils;
pub mod sorted_storages;
mod stake_account;
pub mod stake_history;
mod stake_rewards;
pub mod stake_weighted_timestamp;
pub mod stakes;
pub mod static_ids;

View File

@ -719,7 +719,7 @@ mod test_bank_serialize {
// This some what long test harness is required to freeze the ABI of
// Bank's serialization due to versioned nature
#[frozen_abi(digest = "9BucA5MtPMNNUjADyV27vNgzvDy1RqCLH2gRq5NEuDEF")]
#[frozen_abi(digest = "8LhKH71kTwmagxUGJA6Es58p8fejJsSAdgEmtL3xZdoY")]
#[derive(Serialize, AbiExample)]
pub struct BankAbiTestWrapperNewer {
#[serde(serialize_with = "wrapper_newer")]

View File

@ -0,0 +1,19 @@
//! Code for stake and vote rewards
use {
crate::bank::RewardInfo,
solana_sdk::{account::AccountSharedData, pubkey::Pubkey},
};
#[derive(AbiExample, Debug, Serialize, Deserialize, Clone, PartialEq)]
pub(crate) struct StakeReward {
pub(crate) stake_pubkey: Pubkey,
pub(crate) stake_reward_info: RewardInfo,
pub(crate) stake_account: AccountSharedData,
}
impl StakeReward {
pub(crate) fn get_stake_reward(&self) -> i64 {
self.stake_reward_info.lamports
}
}