Skip to content

Commit

Permalink
PR cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
carllin committed Oct 13, 2020
1 parent 722b2c8 commit 7cf6b4c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
9 changes: 2 additions & 7 deletions programs/bpf/tests/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,8 @@ fn process_transaction_and_record_inner(
let signature = tx.signatures.get(0).unwrap().clone();
let txs = vec![tx];
let tx_batch = bank.prepare_batch(&txs, None);
let (mut results, _, mut inner, _transaction_logs) = bank.load_execute_and_commit_transactions(
&tx_batch,
MAX_PROCESSING_AGE,
false,
true,
false,
);
let (mut results, _, mut inner, _transaction_logs) =
bank.load_execute_and_commit_transactions(&tx_batch, MAX_PROCESSING_AGE, false, true, false);
let inner_instructions = inner.swap_remove(0);
let result = results
.fee_collection_results
Expand Down
30 changes: 17 additions & 13 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,11 +1107,12 @@ impl AccountsDB {
start.stop();
update_index_elapsed = start.as_us();

let mut start = Measure::start("update_index_elapsed");
let mut start = Measure::start("handle_reclaims_elapsed");
self.handle_reclaims(&reclaims, Some(slot), true, None);
start.stop();
handle_reclaims_elapsed = start.as_us();

let mut start = Measure::start("write_storage_elapsed");
if let Some(slot_stores) = self.storage.get_slot_stores(slot) {
slot_stores.write().unwrap().retain(|_key, store| {
if store.count() == 0 {
Expand Down Expand Up @@ -1227,11 +1228,8 @@ impl AccountsDB {
let mut collector = A::default();
let accounts_index = self.accounts_index.read().unwrap();
accounts_index.scan_accounts(ancestors, |pubkey, (account_info, slot)| {
let account_storage_entry = self
.storage
.get_account_storage_entry(slot, account_info.store_id);
let account_slot = account_storage_entry
.and_then(|account_storage_entry| account_storage_entry.get_account(account_info))
let account_slot = self
.get_account_from_storage(slot, account_info)
.map(|account| (pubkey, account, slot));
scan_func(&mut collector, account_slot)
});
Expand All @@ -1247,11 +1245,8 @@ impl AccountsDB {
let mut collector = A::default();
let accounts_index = self.accounts_index.read().unwrap();
accounts_index.range_scan_accounts(ancestors, range, |pubkey, (account_info, slot)| {
let account_storage_entry = self
.storage
.get_account_storage_entry(slot, account_info.store_id);
let account_slot = account_storage_entry
.and_then(|account_storage_entry| account_storage_entry.get_account(account_info))
let account_slot = self
.get_account_from_storage(slot, account_info)
.map(|account| (pubkey, account, slot));
scan_func(&mut collector, account_slot)
});
Expand Down Expand Up @@ -1350,6 +1345,14 @@ impl AccountsDB {
Self::load(&self.storage, ancestors, &accounts_index, pubkey)
}

fn get_account_from_storage(&self, slot: Slot, account_info: &AccountInfo) -> Option<Account> {
let account_storage_entry = self
.storage
.get_account_storage_entry(slot, account_info.store_id);
account_storage_entry
.and_then(|account_storage_entry| account_storage_entry.get_account(account_info))
}

fn find_storage_candidate(&self, slot: Slot) -> Arc<AccountStorageEntry> {
let mut create_extra = false;
let slot_stores_lock = self.storage.get_slot_stores(slot);
Expand Down Expand Up @@ -2139,7 +2142,8 @@ impl AccountsDB {
{
assert_eq!(
*slot, store.slot,
"AccountDB::accounts_index corrupted. Storage should only point to one slot"
"AccountDB::accounts_index corrupted. Storage pointed to: {}, expected: {}, should only point to one slot",
store.slot, *slot
);
let count = store.remove_account();
if count == 0 {
Expand Down Expand Up @@ -2363,7 +2367,7 @@ impl AccountsDB {

pub fn generate_index(&self) {
let mut accounts_index = self.accounts_index.write().unwrap();
let mut slots: Vec<Slot> = self.storage.all_slots();
let mut slots = self.storage.all_slots();
slots.sort();

let mut last_log_update = Instant::now();
Expand Down

0 comments on commit 7cf6b4c

Please sign in to comment.