entry_id -> entry

This commit is contained in:
Michael Vines 2019-03-01 12:23:30 -08:00
parent 67b6be66c8
commit a72325dbc2
3 changed files with 21 additions and 13 deletions

View File

@ -393,7 +393,7 @@ impl Bank {
txs.iter()
.zip(lock_results.into_iter())
.map(|(tx, lock_res)| {
if lock_res.is_ok() && !hash_queue.check_entry_id_age(tx.last_id, max_age) {
if lock_res.is_ok() && !hash_queue.check_entry_age(tx.last_id, max_age) {
error_counters.reserve_last_id += 1;
Err(BankError::LastIdNotFound)
} else {
@ -594,7 +594,8 @@ impl Bank {
#[must_use]
pub fn process_transactions(&self, txs: &[Transaction]) -> Vec<Result<()>> {
let lock_results = self.lock_accounts(txs);
let results = self.load_execute_and_commit_transactions(txs, lock_results, MAX_RECENT_TICK_HASHES);
let results =
self.load_execute_and_commit_transactions(txs, lock_results, MAX_RECENT_TICK_HASHES);
self.unlock_accounts(txs, &results);
results
}
@ -1200,8 +1201,11 @@ mod tests {
let pay_alice = vec![tx1];
let lock_result = bank.lock_accounts(&pay_alice);
let results_alice =
bank.load_execute_and_commit_transactions(&pay_alice, lock_result, MAX_RECENT_TICK_HASHES);
let results_alice = bank.load_execute_and_commit_transactions(
&pay_alice,
lock_result,
MAX_RECENT_TICK_HASHES,
);
assert_eq!(results_alice[0], Ok(()));
// try executing an interleaved transfer twice

View File

@ -38,10 +38,10 @@ impl HashQueue {
self.last_hash.expect("no hash has been set")
}
/// Check if the age of the entry_id is within the max_age
/// Check if the age of the entry is within the max_age
/// return false for any entries with an age equal to or above max_age
pub fn check_entry_id_age(&self, entry_id: Hash, max_age: usize) -> bool {
let entry = self.entries.get(&entry_id);
pub fn check_entry_age(&self, entry: Hash, max_age: usize) -> bool {
let entry = self.entries.get(&entry);
match entry {
Some(entry) => self.hash_height - entry.hash_height < max_age as u64,
_ => false,
@ -49,8 +49,8 @@ impl HashQueue {
}
/// check if entry is valid
#[cfg(test)]
pub fn check_entry(&self, entry_id: Hash) -> bool {
self.entries.get(&entry_id).is_some()
pub fn check_entry(&self, entry: Hash) -> bool {
self.entries.get(&entry).is_some()
}
pub fn genesis_hash(&mut self, hash: &Hash) {
@ -72,8 +72,9 @@ impl HashQueue {
// this clean up can be deferred until sigs gets larger
// because we verify entry.nth every place we check for validity
if self.entries.len() >= MAX_RECENT_TICK_HASHES as usize {
self.entries
.retain(|_, entry| hash_height - entry.hash_height <= MAX_RECENT_TICK_HASHES as u64);
self.entries.retain(|_, entry| {
hash_height - entry.hash_height <= MAX_RECENT_TICK_HASHES as u64
});
}
self.entries.insert(

View File

@ -172,8 +172,11 @@ impl BankingStage {
// the likelihood of any single thread getting starved and processing old ids.
// TODO: Banking stage threads should be prioritized to complete faster then this queue
// expires.
let (loaded_accounts, results) =
bank.load_and_execute_transactions(txs, lock_results, MAX_RECENT_TICK_HASHES as usize / 2);
let (loaded_accounts, results) = bank.load_and_execute_transactions(
txs,
lock_results,
MAX_RECENT_TICK_HASHES as usize / 2,
);
let load_execute_time = now.elapsed();
let record_time = {