.lamports = <number> -> .set_lamports(<number>) (#16746)
This commit is contained in:
parent
8a6b80095e
commit
333998d008
|
@ -31,7 +31,7 @@ use solana_runtime::{
|
|||
snapshot_utils::SnapshotVersion,
|
||||
};
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
clock::{Epoch, Slot},
|
||||
feature::{self, Feature},
|
||||
feature_set,
|
||||
|
@ -1899,14 +1899,14 @@ fn main() {
|
|||
.get_program_accounts(&solana_stake_program::id())
|
||||
.into_iter()
|
||||
{
|
||||
account.lamports = 0;
|
||||
account.set_lamports(0);
|
||||
bank.store_account(&address, &account);
|
||||
}
|
||||
}
|
||||
|
||||
for address in accounts_to_remove {
|
||||
if let Some(mut account) = bank.get_account(&address) {
|
||||
account.lamports = 0;
|
||||
account.set_lamports(0);
|
||||
bank.store_account(&address, &account);
|
||||
}
|
||||
}
|
||||
|
@ -1932,7 +1932,7 @@ fn main() {
|
|||
.get_program_accounts(&solana_vote_program::id())
|
||||
.into_iter()
|
||||
{
|
||||
account.lamports = 0;
|
||||
account.set_lamports(0);
|
||||
bank.store_account(&address, &account);
|
||||
}
|
||||
|
||||
|
|
|
@ -7418,19 +7418,19 @@ pub mod tests {
|
|||
db.store_uncached(0, &[(&frozen_pubkey, &account)]);
|
||||
|
||||
// Store with an increase in lamports is ok
|
||||
account.lamports = 2;
|
||||
account.set_lamports(2);
|
||||
db.store_uncached(0, &[(&frozen_pubkey, &account)]);
|
||||
|
||||
// Store with an decrease that does not go below the frozen amount of lamports is tolerated
|
||||
account.lamports = 1;
|
||||
account.set_lamports(1);
|
||||
db.store_uncached(0, &[(&frozen_pubkey, &account)]);
|
||||
|
||||
// A store of any value over the frozen value of '1' across different slots is also ok
|
||||
account.lamports = 3;
|
||||
account.set_lamports(3);
|
||||
db.store_uncached(1, &[(&frozen_pubkey, &account)]);
|
||||
account.lamports = 2;
|
||||
account.set_lamports(2);
|
||||
db.store_uncached(2, &[(&frozen_pubkey, &account)]);
|
||||
account.lamports = 1;
|
||||
account.set_lamports(1);
|
||||
db.store_uncached(3, &[(&frozen_pubkey, &account)]);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_inf
|
|||
use solana_sdk::{
|
||||
account::{
|
||||
create_account_shared_data_with_fields as create_account, from_account, Account,
|
||||
AccountSharedData, InheritableAccountFields, ReadableAccount,
|
||||
AccountSharedData, InheritableAccountFields, ReadableAccount, WritableAccount,
|
||||
},
|
||||
clock::{
|
||||
Epoch, Slot, SlotCount, SlotIndex, UnixTimestamp, DEFAULT_TICKS_PER_SECOND,
|
||||
|
@ -2213,7 +2213,7 @@ impl Bank {
|
|||
|
||||
// Resetting account balance to 0 is needed to really purge from AccountsDb and
|
||||
// flush the Stakes cache
|
||||
account.lamports = 0;
|
||||
account.set_lamports(0);
|
||||
self.store_account(&program_id, &account);
|
||||
None
|
||||
}
|
||||
|
@ -4988,7 +4988,7 @@ impl Bank {
|
|||
for reward_pubkey in self.rewards_pool_pubkeys.iter() {
|
||||
if let Some(mut reward_account) = self.get_account_with_fixed_root(&reward_pubkey) {
|
||||
if reward_account.lamports == u64::MAX {
|
||||
reward_account.lamports = 0;
|
||||
reward_account.set_lamports(0);
|
||||
self.store_account(&reward_pubkey, &reward_account);
|
||||
// Adjust capitalization.... it has been wrapping, reducing the real capitalization by 1-lamport
|
||||
self.capitalization.fetch_add(1, Relaxed);
|
||||
|
@ -11833,7 +11833,7 @@ pub(crate) mod tests {
|
|||
.copied()
|
||||
.unwrap();
|
||||
let mut bootstrap_stake_account = bank.get_account(&bootstrap_stake_pubkey).unwrap();
|
||||
bootstrap_stake_account.lamports = 10000000;
|
||||
bootstrap_stake_account.set_lamports(10000000);
|
||||
bank.store_account(&bootstrap_stake_pubkey, &bootstrap_stake_account);
|
||||
|
||||
assert_eq!(bank.rewrite_stakes(), (1, 1));
|
||||
|
@ -12110,7 +12110,7 @@ pub(crate) mod tests {
|
|||
.get_account(&validator_vote_keypairs0.vote_keypair.pubkey())
|
||||
.unwrap_or_default();
|
||||
let original_lamports = vote_account.lamports;
|
||||
vote_account.lamports = 0;
|
||||
vote_account.set_lamports(0);
|
||||
// Simulate vote account removal via full withdrawal
|
||||
bank.store_account(
|
||||
&validator_vote_keypairs0.vote_keypair.pubkey(),
|
||||
|
|
|
@ -230,7 +230,7 @@ impl Stakes {
|
|||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use solana_sdk::{pubkey::Pubkey, rent::Rent};
|
||||
use solana_sdk::{account::WritableAccount, pubkey::Pubkey, rent::Rent};
|
||||
use solana_stake_program::stake_state;
|
||||
use solana_vote_program::vote_state::{self, VoteState, VoteStateVersions};
|
||||
|
||||
|
@ -318,7 +318,7 @@ pub mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
stake_account.lamports = 42;
|
||||
stake_account.set_lamports(42);
|
||||
stakes.store(&stake_pubkey, &stake_account, true, true);
|
||||
{
|
||||
let vote_accounts = stakes.vote_accounts();
|
||||
|
@ -342,7 +342,7 @@ pub mod tests {
|
|||
); // now stake of 42 is activated
|
||||
}
|
||||
|
||||
stake_account.lamports = 0;
|
||||
stake_account.set_lamports(0);
|
||||
stakes.store(&stake_pubkey, &stake_account, true, true);
|
||||
{
|
||||
let vote_accounts = stakes.vote_accounts();
|
||||
|
@ -394,7 +394,7 @@ pub mod tests {
|
|||
assert_eq!(vote_accounts.get(&vote_pubkey).unwrap().0, 10);
|
||||
}
|
||||
|
||||
vote_account.lamports = 0;
|
||||
vote_account.set_lamports(0);
|
||||
stakes.store(&vote_pubkey, &vote_account, true, true);
|
||||
|
||||
{
|
||||
|
@ -402,7 +402,7 @@ pub mod tests {
|
|||
assert!(vote_accounts.get(&vote_pubkey).is_none());
|
||||
}
|
||||
|
||||
vote_account.lamports = 1;
|
||||
vote_account.set_lamports(1);
|
||||
stakes.store(&vote_pubkey, &vote_account, true, true);
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue