rework defaults and construction of accountsdb, accounts, bank (#19083)

* rework defaults and construction of accountsdb, accounts, bank

* merge issues
This commit is contained in:
Jeff Washington (jwash)
2021-08-05 17:27:13 -05:00
committed by GitHub
parent e4be00fece
commit 0028442e14
3 changed files with 115 additions and 20 deletions

View File

@@ -87,7 +87,7 @@ impl AccountLocks {
}
/// This structure handles synchronization for db
#[derive(Default, Debug, AbiExample)]
#[derive(Debug, AbiExample)]
pub struct Accounts {
/// Single global AccountsDb
pub accounts_db: Arc<AccountsDb>,
@@ -97,6 +97,15 @@ pub struct Accounts {
pub(crate) account_locks: Mutex<AccountLocks>,
}
impl Default for Accounts {
fn default() -> Self {
Self {
accounts_db: Arc::new(AccountsDb::default()),
account_locks: Mutex::default(),
}
}
}
// for the load instructions
pub type TransactionAccounts = Vec<(Pubkey, AccountSharedData)>;
pub type TransactionRent = u64;
@@ -117,6 +126,13 @@ pub enum AccountAddressFilter {
}
impl Accounts {
pub fn default_for_tests() -> Self {
Self {
accounts_db: Arc::new(AccountsDb::default_for_tests()),
account_locks: Mutex::default(),
}
}
pub fn new(
paths: Vec<PathBuf>,
cluster_type: &ClusterType,