lamports -> lamports() (#16920)
This commit is contained in:
parent
59e19828ea
commit
ca7b36ad8f
|
@ -1558,7 +1558,7 @@ pub fn rewrite_stakes(
|
|||
let meta_status = meta.rewrite_rent_exempt_reserve(rent, stake_account.data().len());
|
||||
let stake_status = stake
|
||||
.delegation
|
||||
.rewrite_stake(stake_account.lamports, meta.rent_exempt_reserve);
|
||||
.rewrite_stake(stake_account.lamports(), meta.rent_exempt_reserve);
|
||||
|
||||
if meta_status.is_none() && stake_status.is_none() {
|
||||
return Err(InstructionError::InvalidAccountData);
|
||||
|
|
|
@ -266,7 +266,7 @@ impl Accounts {
|
|||
if payer_index != 0 {
|
||||
warn!("Payer index should be 0! {:?}", tx);
|
||||
}
|
||||
if accounts[payer_index].lamports == 0 {
|
||||
if accounts[payer_index].lamports() == 0 {
|
||||
error_counters.account_not_found += 1;
|
||||
Err(TransactionError::AccountNotFound)
|
||||
} else {
|
||||
|
@ -283,7 +283,7 @@ impl Accounts {
|
|||
}
|
||||
};
|
||||
|
||||
if accounts[payer_index].lamports < fee + min_balance {
|
||||
if accounts[payer_index].lamports() < fee + min_balance {
|
||||
error_counters.insufficient_funds += 1;
|
||||
Err(TransactionError::InsufficientFundsForFee)
|
||||
} else {
|
||||
|
@ -574,7 +574,7 @@ impl Accounts {
|
|||
ancestors,
|
||||
|collector: &mut BinaryHeap<Reverse<(u64, Pubkey)>>, option| {
|
||||
if let Some((pubkey, account, _slot)) = option {
|
||||
if account.lamports == 0 {
|
||||
if account.lamports() == 0 {
|
||||
return;
|
||||
}
|
||||
let contains_address = filter_by_address.contains(pubkey);
|
||||
|
@ -589,12 +589,12 @@ impl Accounts {
|
|||
let Reverse(entry) = collector
|
||||
.peek()
|
||||
.expect("BinaryHeap::peek should succeed when len > 0");
|
||||
if *entry >= (account.lamports, *pubkey) {
|
||||
if *entry >= (account.lamports(), *pubkey) {
|
||||
return;
|
||||
}
|
||||
collector.pop();
|
||||
}
|
||||
collector.push(Reverse((account.lamports, *pubkey)));
|
||||
collector.push(Reverse((account.lamports(), *pubkey)));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
@ -651,7 +651,7 @@ impl Accounts {
|
|||
filter: F,
|
||||
) {
|
||||
if let Some(mapped_account_tuple) = some_account_tuple
|
||||
.filter(|(_, account, _)| Self::is_loadable(account.lamports) && filter(account))
|
||||
.filter(|(_, account, _)| Self::is_loadable(account.lamports()) && filter(account))
|
||||
.map(|(pubkey, account, _slot)| (*pubkey, account))
|
||||
{
|
||||
collector.push(mapped_account_tuple)
|
||||
|
@ -708,8 +708,8 @@ impl Accounts {
|
|||
self.accounts_db.scan_accounts(
|
||||
ancestors,
|
||||
|collector: &mut Vec<(Pubkey, AccountSharedData, Slot)>, some_account_tuple| {
|
||||
if let Some((pubkey, account, slot)) =
|
||||
some_account_tuple.filter(|(_, account, _)| Self::is_loadable(account.lamports))
|
||||
if let Some((pubkey, account, slot)) = some_account_tuple
|
||||
.filter(|(_, account, _)| Self::is_loadable(account.lamports()))
|
||||
{
|
||||
collector.push((*pubkey, account, slot))
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@ impl<'a> LoadedAccount<'a> {
|
|||
pub fn lamports(&self) -> u64 {
|
||||
match self {
|
||||
LoadedAccount::Stored(stored_account_meta) => stored_account_meta.account_meta.lamports,
|
||||
LoadedAccount::Cached((_, cached_account)) => cached_account.account.lamports,
|
||||
LoadedAccount::Cached((_, cached_account)) => cached_account.account.lamports(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4516,7 +4516,7 @@ impl AccountsDb {
|
|||
{
|
||||
let frozen_account_info = FrozenAccountInfo {
|
||||
hash: Self::hash_frozen_account_data(&account),
|
||||
lamports: account.lamports,
|
||||
lamports: account.lamports(),
|
||||
};
|
||||
warn!(
|
||||
"Account {} is now frozen at lamports={}, hash={}",
|
||||
|
@ -4540,11 +4540,13 @@ impl AccountsDb {
|
|||
}
|
||||
for (account_pubkey, account) in accounts.iter() {
|
||||
if let Some(frozen_account_info) = self.frozen_accounts.get(*account_pubkey) {
|
||||
if account.lamports < frozen_account_info.lamports {
|
||||
if account.lamports() < frozen_account_info.lamports {
|
||||
FROZEN_ACCOUNT_PANIC.store(true, Ordering::Relaxed);
|
||||
panic!(
|
||||
"Frozen account {} modified. Lamports decreased from {} to {}",
|
||||
account_pubkey, frozen_account_info.lamports, account.lamports,
|
||||
account_pubkey,
|
||||
frozen_account_info.lamports,
|
||||
account.lamports(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1378,7 +1378,7 @@ impl Bank {
|
|||
old_account: &Option<AccountSharedData>,
|
||||
) -> InheritableAccountFields {
|
||||
(
|
||||
old_account.as_ref().map(|a| a.lamports).unwrap_or(1),
|
||||
old_account.as_ref().map(|a| a.lamports()).unwrap_or(1),
|
||||
INITIAL_RENT_EPOCH,
|
||||
)
|
||||
}
|
||||
|
@ -1854,7 +1854,7 @@ impl Bank {
|
|||
// pay according to point value
|
||||
for (vote_pubkey, (stake_group, vote_account)) in stake_delegation_accounts.iter_mut() {
|
||||
let mut vote_account_changed = false;
|
||||
let voters_account_pre_balance = vote_account.lamports;
|
||||
let voters_account_pre_balance = vote_account.lamports();
|
||||
|
||||
for (stake_pubkey, stake_account) in stake_group.iter_mut() {
|
||||
// curry closure to add the contextual stake_pubkey
|
||||
|
@ -1884,7 +1884,7 @@ impl Bank {
|
|||
RewardInfo {
|
||||
reward_type: RewardType::Staking,
|
||||
lamports: stakers_reward as i64,
|
||||
post_balance: stake_account.lamports,
|
||||
post_balance: stake_account.lamports(),
|
||||
},
|
||||
));
|
||||
}
|
||||
|
@ -1897,7 +1897,7 @@ impl Bank {
|
|||
}
|
||||
|
||||
if vote_account_changed {
|
||||
let post_balance = vote_account.lamports;
|
||||
let post_balance = vote_account.lamports();
|
||||
let lamports = (post_balance - voters_account_pre_balance) as i64;
|
||||
if lamports != 0 {
|
||||
rewards.push((
|
||||
|
@ -2209,7 +2209,7 @@ impl Bank {
|
|||
// malicious account is pre-occupying at program_id
|
||||
// forcibly burn and purge it
|
||||
|
||||
self.capitalization.fetch_sub(account.lamports, Relaxed);
|
||||
self.capitalization.fetch_sub(account.lamports(), Relaxed);
|
||||
|
||||
// Resetting account balance to 0 is needed to really purge from AccountsDb and
|
||||
// flush the Stakes cache
|
||||
|
@ -3381,7 +3381,7 @@ impl Bank {
|
|||
RewardInfo {
|
||||
reward_type: RewardType::Rent,
|
||||
lamports: rent_to_be_paid as i64,
|
||||
post_balance: account.lamports,
|
||||
post_balance: account.lamports(),
|
||||
},
|
||||
));
|
||||
}
|
||||
|
@ -3444,7 +3444,7 @@ impl Bank {
|
|||
if let Some((account, _)) =
|
||||
self.get_account_modified_since_parent_with_fixed_root(&incinerator::id())
|
||||
{
|
||||
self.capitalization.fetch_sub(account.lamports, Relaxed);
|
||||
self.capitalization.fetch_sub(account.lamports(), Relaxed);
|
||||
self.store_account(&incinerator::id(), &AccountSharedData::default());
|
||||
}
|
||||
}
|
||||
|
@ -3931,7 +3931,7 @@ impl Bank {
|
|||
}
|
||||
|
||||
pub fn read_balance(account: &AccountSharedData) -> u64 {
|
||||
account.lamports
|
||||
account.lamports()
|
||||
}
|
||||
/// Each program would need to be able to introspect its own state
|
||||
/// this is hard-coded to the Budget language
|
||||
|
@ -4001,19 +4001,20 @@ impl Bank {
|
|||
new_account: &AccountSharedData,
|
||||
) {
|
||||
if let Some(old_account) = self.get_account_with_fixed_root(&pubkey) {
|
||||
match new_account.lamports.cmp(&old_account.lamports) {
|
||||
match new_account.lamports().cmp(&old_account.lamports()) {
|
||||
std::cmp::Ordering::Greater => {
|
||||
self.capitalization
|
||||
.fetch_add(new_account.lamports - old_account.lamports, Relaxed);
|
||||
.fetch_add(new_account.lamports() - old_account.lamports(), Relaxed);
|
||||
}
|
||||
std::cmp::Ordering::Less => {
|
||||
self.capitalization
|
||||
.fetch_sub(old_account.lamports - new_account.lamports, Relaxed);
|
||||
.fetch_sub(old_account.lamports() - new_account.lamports(), Relaxed);
|
||||
}
|
||||
std::cmp::Ordering::Equal => {}
|
||||
}
|
||||
} else {
|
||||
self.capitalization.fetch_add(new_account.lamports, Relaxed);
|
||||
self.capitalization
|
||||
.fetch_add(new_account.lamports(), Relaxed);
|
||||
}
|
||||
|
||||
self.store_account(pubkey, new_account);
|
||||
|
@ -4051,7 +4052,7 @@ impl Bank {
|
|||
let mut account = self.get_account_with_fixed_root(pubkey).unwrap_or_default();
|
||||
account.lamports += lamports;
|
||||
self.store_account(pubkey, &account);
|
||||
account.lamports
|
||||
account.lamports()
|
||||
}
|
||||
|
||||
pub fn accounts(&self) -> Arc<Accounts> {
|
||||
|
@ -4917,7 +4918,8 @@ impl Bank {
|
|||
);
|
||||
|
||||
// Burn lamports in the old token account
|
||||
self.capitalization.fetch_sub(old_account.lamports, Relaxed);
|
||||
self.capitalization
|
||||
.fetch_sub(old_account.lamports(), Relaxed);
|
||||
|
||||
// Transfer new token account to old token account
|
||||
self.store_account(&inline_spl_token_v2_0::id(), &new_account);
|
||||
|
@ -4963,7 +4965,7 @@ impl Bank {
|
|||
}
|
||||
} else {
|
||||
self.capitalization
|
||||
.fetch_add(native_mint_account.lamports, Relaxed);
|
||||
.fetch_add(native_mint_account.lamports(), Relaxed);
|
||||
true
|
||||
};
|
||||
|
||||
|
@ -4990,7 +4992,7 @@ impl Bank {
|
|||
if purge_window_epoch {
|
||||
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 {
|
||||
if reward_account.lamports() == u64::MAX {
|
||||
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
|
||||
|
|
|
@ -125,13 +125,13 @@ impl PreAccount {
|
|||
|
||||
// An account not assigned to the program cannot have its balance decrease.
|
||||
if program_id != pre.owner() // line coverage used to get branch coverage
|
||||
&& pre.lamports() > post.lamports
|
||||
&& pre.lamports() > post.lamports()
|
||||
{
|
||||
return Err(InstructionError::ExternalAccountLamportSpend);
|
||||
}
|
||||
|
||||
// The balance of read-only and executable accounts may not change
|
||||
let lamports_changed = pre.lamports() != post.lamports;
|
||||
let lamports_changed = pre.lamports() != post.lamports();
|
||||
if lamports_changed {
|
||||
if !is_writable {
|
||||
return Err(InstructionError::ReadonlyLamportChange);
|
||||
|
@ -171,7 +171,7 @@ impl PreAccount {
|
|||
// executable is one-way (false->true) and only the account owner may set it.
|
||||
let executable_changed = pre.executable() != post.executable();
|
||||
if executable_changed {
|
||||
if !rent.is_exempt(post.lamports, post.data().len()) {
|
||||
if !rent.is_exempt(post.lamports(), post.data().len()) {
|
||||
return Err(InstructionError::ExecutableAccountNotRentExempt);
|
||||
}
|
||||
if !is_writable // line coverage used to get branch coverage
|
||||
|
@ -220,7 +220,7 @@ impl PreAccount {
|
|||
}
|
||||
|
||||
pub fn lamports(&self) -> u64 {
|
||||
self.account.borrow().lamports
|
||||
self.account.borrow().lamports()
|
||||
}
|
||||
|
||||
pub fn is_zeroed(buf: &[u8]) -> bool {
|
||||
|
@ -1054,7 +1054,7 @@ impl MessageProcessor {
|
|||
true,
|
||||
)?;
|
||||
pre_sum += u128::from(pre_accounts[unique_index].lamports());
|
||||
post_sum += u128::from(account.lamports);
|
||||
post_sum += u128::from(account.lamports());
|
||||
Ok(())
|
||||
};
|
||||
instruction.visit_each_account(&mut work)?;
|
||||
|
@ -1109,7 +1109,7 @@ impl MessageProcessor {
|
|||
false,
|
||||
)?;
|
||||
pre_sum += u128::from(pre_account.lamports());
|
||||
post_sum += u128::from(account.lamports);
|
||||
post_sum += u128::from(account.lamports());
|
||||
if is_writable && !account.executable() {
|
||||
pre_account.update(&account);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ impl RentCollector {
|
|||
|
||||
let (rent_due, exempt) =
|
||||
self.rent
|
||||
.due(account.lamports, account.data().len(), years_elapsed);
|
||||
.due(account.lamports(), account.data().len(), years_elapsed);
|
||||
|
||||
if exempt || rent_due != 0 {
|
||||
if account.lamports() > rent_due {
|
||||
|
@ -99,7 +99,7 @@ impl RentCollector {
|
|||
account.lamports -= rent_due;
|
||||
rent_due
|
||||
} else {
|
||||
let rent_charged = account.lamports;
|
||||
let rent_charged = account.lamports();
|
||||
*account = AccountSharedData::default();
|
||||
rent_charged
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ impl Stakes {
|
|||
}
|
||||
}
|
||||
|
||||
if account.lamports == 0 {
|
||||
if account.lamports() == 0 {
|
||||
// when account is removed (lamports == 0), remove it from Stakes as well
|
||||
// so that given `pubkey` can be used for any owner in the future, while not
|
||||
// affecting Stakes.
|
||||
|
|
Loading…
Reference in New Issue