Remove unused Accounts state (#15611)

* Remove dead state from Accounts

* Refactor to remove reference to self.slot

Account::default() has zero lamports, so would return None anyway
This commit is contained in:
Greg Fitzgerald 2021-03-02 08:28:25 -08:00 committed by GitHub
parent 2ff6942ed3
commit aad79d9d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 15 deletions

View File

@ -19,7 +19,7 @@ use solana_sdk::{
account::Account,
account_utils::StateMut,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::{Epoch, Slot},
clock::Slot,
feature_set::{self, FeatureSet},
fee_calculator::{FeeCalculator, FeeConfig},
genesis_config::ClusterType,
@ -83,12 +83,6 @@ impl AccountLocks {
/// This structure handles synchronization for db
#[derive(Default, Debug, AbiExample)]
pub struct Accounts {
/// my slot
pub slot: Slot,
/// my epoch
pub epoch: Epoch,
/// Single global AccountsDb
pub accounts_db: Arc<AccountsDb>,
@ -140,12 +134,10 @@ impl Accounts {
}
}
pub fn new_from_parent(parent: &Accounts, slot: Slot, parent_slot: Slot, epoch: Epoch) -> Self {
pub fn new_from_parent(parent: &Accounts, slot: Slot, parent_slot: Slot) -> Self {
let accounts_db = parent.accounts_db.clone();
accounts_db.set_hash(slot, parent_slot);
Self {
slot,
epoch,
accounts_db,
account_locks: Mutex::new(AccountLocks::default()),
}
@ -464,10 +456,7 @@ impl Accounts {
/// Slow because lock is held for 1 operation instead of many
pub fn load_slow(&self, ancestors: &Ancestors, pubkey: &Pubkey) -> Option<(Account, Slot)> {
let (account, slot) = self
.accounts_db
.load_slow(ancestors, pubkey)
.unwrap_or((Account::default(), self.slot));
let (account, slot) = self.accounts_db.load_slow(ancestors, pubkey)?;
if account.lamports > 0 {
Some((account, slot))

View File

@ -980,7 +980,6 @@ impl Bank {
&parent.rc.accounts,
slot,
parent.slot(),
epoch,
)),
parent: RwLock::new(Some(parent.clone())),
slot,