Rename LastIdNotFound to BlockHashNotFound
This commit is contained in:
committed by
Greg Fitzgerald
parent
176d5e0d37
commit
0743f54dfe
@ -443,7 +443,7 @@ mod tests {
|
|||||||
// First, ensure the TX is rejected because of the unregistered last ID
|
// First, ensure the TX is rejected because of the unregistered last ID
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.process_transaction(&tx),
|
bank.process_transaction(&tx),
|
||||||
Err(BankError::LastIdNotFound)
|
Err(BankError::BlockHashNotFound)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Now ensure the TX is accepted despite pointing to the ID of an empty entry.
|
// Now ensure the TX is accepted despite pointing to the ID of an empty entry.
|
||||||
|
@ -50,12 +50,12 @@ pub enum BankError {
|
|||||||
|
|
||||||
/// The bank has seen `Signature` before. This can occur under normal operation
|
/// The bank has seen `Signature` before. This can occur under normal operation
|
||||||
/// when a UDP packet is duplicated, as a user error from a client not updating
|
/// when a UDP packet is duplicated, as a user error from a client not updating
|
||||||
/// its `last_id`, or as a double-spend attack.
|
/// its `recent_block_hash`, or as a double-spend attack.
|
||||||
DuplicateSignature,
|
DuplicateSignature,
|
||||||
|
|
||||||
/// The bank has not seen the given `last_id` or the transaction is too old and
|
/// The bank has not seen the given `recent_block_hash` or the transaction is too old and
|
||||||
/// the `last_id` has been discarded.
|
/// the `recent_block_hash` has been discarded.
|
||||||
LastIdNotFound,
|
BlockHashNotFound,
|
||||||
|
|
||||||
/// Proof of History verification failed.
|
/// Proof of History verification failed.
|
||||||
LedgerVerificationFailed,
|
LedgerVerificationFailed,
|
||||||
@ -85,7 +85,7 @@ pub struct Bank {
|
|||||||
/// A cache of signature statuses
|
/// A cache of signature statuses
|
||||||
status_cache: RwLock<BankStatusCache>,
|
status_cache: RwLock<BankStatusCache>,
|
||||||
|
|
||||||
/// FIFO queue of `last_id` items
|
/// FIFO queue of `recent_block_hash` items
|
||||||
block_hash_queue: RwLock<HashQueue>,
|
block_hash_queue: RwLock<HashQueue>,
|
||||||
|
|
||||||
/// Previous checkpoint of this bank
|
/// Previous checkpoint of this bank
|
||||||
@ -297,7 +297,7 @@ impl Bank {
|
|||||||
self.add_native_program("solana_token_program", &token_program::id());
|
self.add_native_program("solana_token_program", &token_program::id());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the last entry ID registered.
|
/// Return the last block hash registered.
|
||||||
pub fn last_id(&self) -> Hash {
|
pub fn last_id(&self) -> Hash {
|
||||||
self.block_hash_queue.read().unwrap().last_hash()
|
self.block_hash_queue.read().unwrap().last_hash()
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ impl Bank {
|
|||||||
for (i, tx) in txs.iter().enumerate() {
|
for (i, tx) in txs.iter().enumerate() {
|
||||||
match &res[i] {
|
match &res[i] {
|
||||||
Ok(_) => status_cache.add(&tx.signatures[0]),
|
Ok(_) => status_cache.add(&tx.signatures[0]),
|
||||||
Err(BankError::LastIdNotFound) => (),
|
Err(BankError::BlockHashNotFound) => (),
|
||||||
Err(BankError::DuplicateSignature) => (),
|
Err(BankError::DuplicateSignature) => (),
|
||||||
Err(BankError::AccountNotFound) => (),
|
Err(BankError::AccountNotFound) => (),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -427,7 +427,7 @@ impl Bank {
|
|||||||
.map(|(tx, lock_res)| {
|
.map(|(tx, lock_res)| {
|
||||||
if lock_res.is_ok() && !hash_queue.check_entry_age(tx.recent_block_hash, max_age) {
|
if lock_res.is_ok() && !hash_queue.check_entry_age(tx.recent_block_hash, max_age) {
|
||||||
error_counters.reserve_last_id += 1;
|
error_counters.reserve_last_id += 1;
|
||||||
Err(BankError::LastIdNotFound)
|
Err(BankError::BlockHashNotFound)
|
||||||
} else {
|
} else {
|
||||||
lock_res
|
lock_res
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user