Skip to content

Commit

Permalink
chore: add getter by address and nonce to TransactionPool
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware committed Jul 9, 2024
1 parent 4269f5b commit aee5b13
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/mempool/src/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ impl TransactionPool {
Ok(tx)
}

pub fn get(&self, tx_hash: TransactionHash) -> MempoolResult<&ThinTransaction> {
pub fn get_by_tx_hash(&self, tx_hash: TransactionHash) -> MempoolResult<&ThinTransaction> {
self.tx_pool.get(&tx_hash).ok_or(MempoolError::TransactionNotFound { tx_hash })
}

pub fn get_by_address_and_nonce(
&self,
address: ContractAddress,
nonce: Nonce,
) -> Option<&TransactionReference> {
self.txs_by_account.get(address, nonce)
}
}

#[derive(Debug, Default)]
Expand All @@ -85,4 +93,8 @@ impl AccountTransactionIndex {

removed_tx
}

pub fn get(&self, address: ContractAddress, nonce: Nonce) -> Option<&TransactionReference> {
self.0.get(&address)?.get(&nonce)
}
}

0 comments on commit aee5b13

Please sign in to comment.