entry_id -> entry
This commit is contained in:
parent
67b6be66c8
commit
a72325dbc2
|
@ -393,7 +393,7 @@ impl Bank {
|
||||||
txs.iter()
|
txs.iter()
|
||||||
.zip(lock_results.into_iter())
|
.zip(lock_results.into_iter())
|
||||||
.map(|(tx, lock_res)| {
|
.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;
|
error_counters.reserve_last_id += 1;
|
||||||
Err(BankError::LastIdNotFound)
|
Err(BankError::LastIdNotFound)
|
||||||
} else {
|
} else {
|
||||||
|
@ -594,7 +594,8 @@ impl Bank {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn process_transactions(&self, txs: &[Transaction]) -> Vec<Result<()>> {
|
pub fn process_transactions(&self, txs: &[Transaction]) -> Vec<Result<()>> {
|
||||||
let lock_results = self.lock_accounts(txs);
|
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);
|
self.unlock_accounts(txs, &results);
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
@ -1200,8 +1201,11 @@ mod tests {
|
||||||
let pay_alice = vec![tx1];
|
let pay_alice = vec![tx1];
|
||||||
|
|
||||||
let lock_result = bank.lock_accounts(&pay_alice);
|
let lock_result = bank.lock_accounts(&pay_alice);
|
||||||
let results_alice =
|
let results_alice = bank.load_execute_and_commit_transactions(
|
||||||
bank.load_execute_and_commit_transactions(&pay_alice, lock_result, MAX_RECENT_TICK_HASHES);
|
&pay_alice,
|
||||||
|
lock_result,
|
||||||
|
MAX_RECENT_TICK_HASHES,
|
||||||
|
);
|
||||||
assert_eq!(results_alice[0], Ok(()));
|
assert_eq!(results_alice[0], Ok(()));
|
||||||
|
|
||||||
// try executing an interleaved transfer twice
|
// try executing an interleaved transfer twice
|
||||||
|
|
|
@ -38,10 +38,10 @@ impl HashQueue {
|
||||||
self.last_hash.expect("no hash has been set")
|
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
|
/// 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 {
|
pub fn check_entry_age(&self, entry: Hash, max_age: usize) -> bool {
|
||||||
let entry = self.entries.get(&entry_id);
|
let entry = self.entries.get(&entry);
|
||||||
match entry {
|
match entry {
|
||||||
Some(entry) => self.hash_height - entry.hash_height < max_age as u64,
|
Some(entry) => self.hash_height - entry.hash_height < max_age as u64,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
@ -49,8 +49,8 @@ impl HashQueue {
|
||||||
}
|
}
|
||||||
/// check if entry is valid
|
/// check if entry is valid
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn check_entry(&self, entry_id: Hash) -> bool {
|
pub fn check_entry(&self, entry: Hash) -> bool {
|
||||||
self.entries.get(&entry_id).is_some()
|
self.entries.get(&entry).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn genesis_hash(&mut self, hash: &Hash) {
|
pub fn genesis_hash(&mut self, hash: &Hash) {
|
||||||
|
@ -72,8 +72,9 @@ impl HashQueue {
|
||||||
// this clean up can be deferred until sigs gets larger
|
// this clean up can be deferred until sigs gets larger
|
||||||
// because we verify entry.nth every place we check for validity
|
// because we verify entry.nth every place we check for validity
|
||||||
if self.entries.len() >= MAX_RECENT_TICK_HASHES as usize {
|
if self.entries.len() >= MAX_RECENT_TICK_HASHES as usize {
|
||||||
self.entries
|
self.entries.retain(|_, entry| {
|
||||||
.retain(|_, entry| hash_height - entry.hash_height <= MAX_RECENT_TICK_HASHES as u64);
|
hash_height - entry.hash_height <= MAX_RECENT_TICK_HASHES as u64
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
self.entries.insert(
|
self.entries.insert(
|
||||||
|
|
|
@ -172,8 +172,11 @@ impl BankingStage {
|
||||||
// the likelihood of any single thread getting starved and processing old ids.
|
// 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
|
// TODO: Banking stage threads should be prioritized to complete faster then this queue
|
||||||
// expires.
|
// expires.
|
||||||
let (loaded_accounts, results) =
|
let (loaded_accounts, results) = bank.load_and_execute_transactions(
|
||||||
bank.load_and_execute_transactions(txs, lock_results, MAX_RECENT_TICK_HASHES as usize / 2);
|
txs,
|
||||||
|
lock_results,
|
||||||
|
MAX_RECENT_TICK_HASHES as usize / 2,
|
||||||
|
);
|
||||||
let load_execute_time = now.elapsed();
|
let load_execute_time = now.elapsed();
|
||||||
|
|
||||||
let record_time = {
|
let record_time = {
|
||||||
|
|
Loading…
Reference in New Issue