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_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))
|
||||
|
|
|
@ -980,7 +980,6 @@ impl Bank {
|
|||
&parent.rc.accounts,
|
||||
slot,
|
||||
parent.slot(),
|
||||
epoch,
|
||||
)),
|
||||
parent: RwLock::new(Some(parent.clone())),
|
||||
slot,
|
||||
|
|
Loading…
Reference in New Issue