type AccountSecondaryIndexes = HashSet (#17108)
This commit is contained in:
committed by
GitHub
parent
a6a1355b80
commit
f39dda00e0
@@ -2,7 +2,7 @@ use crate::{
|
||||
accounts_db::{
|
||||
AccountsDb, BankHashInfo, ErrorCounters, LoadHint, LoadedAccount, ScanStorageResult,
|
||||
},
|
||||
accounts_index::{AccountIndex, Ancestors, IndexKey},
|
||||
accounts_index::{AccountSecondaryIndexes, Ancestors, IndexKey},
|
||||
bank::{
|
||||
NonceRollbackFull, NonceRollbackInfo, TransactionCheckResult, TransactionExecutionResult,
|
||||
},
|
||||
@@ -115,13 +115,18 @@ pub enum AccountAddressFilter {
|
||||
|
||||
impl Accounts {
|
||||
pub fn new(paths: Vec<PathBuf>, cluster_type: &ClusterType) -> Self {
|
||||
Self::new_with_config(paths, cluster_type, HashSet::new(), false)
|
||||
Self::new_with_config(
|
||||
paths,
|
||||
cluster_type,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_with_config(
|
||||
paths: Vec<PathBuf>,
|
||||
cluster_type: &ClusterType,
|
||||
account_indexes: HashSet<AccountIndex>,
|
||||
account_indexes: AccountSecondaryIndexes,
|
||||
caching_enabled: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -1088,8 +1093,12 @@ mod tests {
|
||||
) -> Vec<TransactionLoadResult> {
|
||||
let mut hash_queue = BlockhashQueue::new(100);
|
||||
hash_queue.register_hash(&tx.message().recent_blockhash, &fee_calculator);
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
for ka in ka.iter() {
|
||||
accounts.store_slow_uncached(0, &ka.0, &ka.1);
|
||||
}
|
||||
@@ -1621,8 +1630,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_load_by_program_slot() {
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
|
||||
// Load accounts owned by various programs into AccountsDb
|
||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
||||
@@ -1645,8 +1658,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_accounts_account_not_found() {
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
let mut error_counters = ErrorCounters::default();
|
||||
let ancestors = vec![(0, 0)].into_iter().collect();
|
||||
|
||||
@@ -1664,8 +1681,12 @@ mod tests {
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_accounts_empty_bank_hash() {
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
accounts.bank_hash_at(1);
|
||||
}
|
||||
|
||||
@@ -1681,8 +1702,12 @@ mod tests {
|
||||
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
||||
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
|
||||
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
accounts.store_slow_uncached(0, &keypair0.pubkey(), &account0);
|
||||
accounts.store_slow_uncached(0, &keypair1.pubkey(), &account1);
|
||||
accounts.store_slow_uncached(0, &keypair2.pubkey(), &account2);
|
||||
@@ -1803,8 +1828,12 @@ mod tests {
|
||||
let account1 = AccountSharedData::new(2, 0, &Pubkey::default());
|
||||
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
||||
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
accounts.store_slow_uncached(0, &keypair0.pubkey(), &account0);
|
||||
accounts.store_slow_uncached(0, &keypair1.pubkey(), &account1);
|
||||
accounts.store_slow_uncached(0, &keypair2.pubkey(), &account2);
|
||||
@@ -1947,8 +1976,12 @@ mod tests {
|
||||
|
||||
let mut loaded = vec![loaded0, loaded1];
|
||||
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
{
|
||||
accounts
|
||||
.account_locks
|
||||
@@ -1995,8 +2028,12 @@ mod tests {
|
||||
#[test]
|
||||
fn huge_clean() {
|
||||
solana_logger::setup();
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
let mut old_pubkey = Pubkey::default();
|
||||
let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
|
||||
info!("storing..");
|
||||
@@ -2038,8 +2075,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_instructions() {
|
||||
solana_logger::setup();
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
|
||||
let instructions_key = solana_sdk::sysvar::instructions::id();
|
||||
let keypair = Keypair::new();
|
||||
@@ -2318,8 +2359,12 @@ mod tests {
|
||||
let mut loaded = vec![loaded];
|
||||
|
||||
let next_blockhash = Hash::new_unique();
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
let collected_accounts = accounts.collect_accounts_to_store(
|
||||
txs.iter(),
|
||||
&loaders,
|
||||
@@ -2432,8 +2477,12 @@ mod tests {
|
||||
let mut loaded = vec![loaded];
|
||||
|
||||
let next_blockhash = Hash::new_unique();
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
let collected_accounts = accounts.collect_accounts_to_store(
|
||||
txs.iter(),
|
||||
&loaders,
|
||||
@@ -2462,8 +2511,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_load_largest_accounts() {
|
||||
let accounts =
|
||||
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
|
||||
let accounts = Accounts::new_with_config(
|
||||
Vec::new(),
|
||||
&ClusterType::Development,
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
);
|
||||
|
||||
let pubkey0 = Pubkey::new_unique();
|
||||
let account0 = AccountSharedData::new(42, 0, &Pubkey::default());
|
||||
|
Reference in New Issue
Block a user