Refactors Accounts::new() fns (#30343)
This commit is contained in:
parent
ba43883cce
commit
5680c76c86
|
@ -142,10 +142,7 @@ pub enum AccountAddressFilter {
|
||||||
|
|
||||||
impl Accounts {
|
impl Accounts {
|
||||||
pub fn default_for_tests() -> Self {
|
pub fn default_for_tests() -> Self {
|
||||||
Self {
|
Self::new_empty(AccountsDb::default_for_tests())
|
||||||
accounts_db: Arc::new(AccountsDb::default_for_tests()),
|
|
||||||
account_locks: Mutex::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_config_for_tests(
|
pub fn new_with_config_for_tests(
|
||||||
|
@ -191,8 +188,7 @@ impl Accounts {
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
||||||
exit: &Arc<AtomicBool>,
|
exit: &Arc<AtomicBool>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self::new_empty(AccountsDb::new_with_config(
|
||||||
accounts_db: Arc::new(AccountsDb::new_with_config(
|
|
||||||
paths,
|
paths,
|
||||||
cluster_type,
|
cluster_type,
|
||||||
account_indexes,
|
account_indexes,
|
||||||
|
@ -200,23 +196,22 @@ impl Accounts {
|
||||||
accounts_db_config,
|
accounts_db_config,
|
||||||
accounts_update_notifier,
|
accounts_update_notifier,
|
||||||
exit,
|
exit,
|
||||||
)),
|
))
|
||||||
account_locks: Mutex::new(AccountLocks::default()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_parent(parent: &Accounts, slot: Slot, parent_slot: Slot) -> 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.insert_default_bank_hash_stats(slot, parent_slot);
|
accounts_db.insert_default_bank_hash_stats(slot, parent_slot);
|
||||||
Self {
|
Self::new(accounts_db)
|
||||||
accounts_db,
|
|
||||||
account_locks: Mutex::new(AccountLocks::default()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn new_empty(accounts_db: AccountsDb) -> Self {
|
pub(crate) fn new_empty(accounts_db: AccountsDb) -> Self {
|
||||||
|
Self::new(Arc::new(accounts_db))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new(accounts_db: Arc<AccountsDb>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
accounts_db: Arc::new(accounts_db),
|
accounts_db,
|
||||||
account_locks: Mutex::new(AccountLocks::default()),
|
account_locks: Mutex::new(AccountLocks::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue