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