Skip to content

Commit

Permalink
refactor(mempool): add error message in transaction queue (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 authored Jul 10, 2024
1 parent 025f4c3 commit 60ec73d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/mempool/src/transaction_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ pub struct TransactionQueue {
impl TransactionQueue {
/// Adds a transaction to the mempool, ensuring unique keys.
/// Panics: if given a duplicate tx.
// TODO(Mohammad): Add test for two transactions from the same address, expecting specific
// assert.
pub fn insert(&mut self, tx: TransactionReference) {
assert_eq!(self.address_to_tx.insert(tx.sender_address, tx), None);
assert_eq!(
self.address_to_tx.insert(tx.sender_address, tx),
None,
"Only a single transaction from the same contract class can be in the mempool at a \
time."
);
assert!(
self.queue.insert(tx.into()),
"Keys should be unique; duplicates are checked prior."
Expand Down

0 comments on commit 60ec73d

Please sign in to comment.