Skip to content

Commit

Permalink
refactor(mempool): add error message in transaction queue
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 committed Jul 9, 2024
1 parent 6e74e3f commit 47b6b35
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_nonce.insert(tx.sender_address, tx.nonce), None);
assert_eq!(
self.address_to_nonce.insert(tx.sender_address, tx.nonce),
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 47b6b35

Please sign in to comment.