pub trait Mempool {
// Required methods
fn store_mempool_tx(
&mut self,
tx: &Transaction,
timestamp: u64,
) -> Result<()>;
fn mempool_tx(&self, tx_id: [u8; 32]) -> Result<Option<Transaction>>;
fn mempool_tx_exists(&self, tx_id: [u8; 32]) -> Result<bool>;
fn delete_mempool_tx(
&mut self,
tx_id: [u8; 32],
cascade: bool,
) -> Result<Vec<[u8; 32]>>;
fn mempool_txs_by_spendable_ids(
&self,
n: &[SpendingId],
) -> HashSet<[u8; 32]>;
fn mempool_txs_sorted_by_fee(
&self,
) -> Result<Box<dyn Iterator<Item = Transaction> + '_>>;
fn mempool_txs_ids_sorted_by_fee(
&self,
) -> Result<Box<dyn Iterator<Item = (u64, [u8; 32])> + '_>>;
fn mempool_txs_ids_sorted_by_low_fee(
&self,
) -> Result<Box<dyn Iterator<Item = (u64, [u8; 32])> + '_>>;
fn mempool_txs_ids(&self) -> Result<Vec<[u8; 32]>>;
fn mempool_expired_txs(&self, timestamp: u64) -> Result<Vec<[u8; 32]>>;
fn mempool_txs_count(&self) -> usize;
}Required Methods§
Sourcefn store_mempool_tx(&mut self, tx: &Transaction, timestamp: u64) -> Result<()>
fn store_mempool_tx(&mut self, tx: &Transaction, timestamp: u64) -> Result<()>
Adds a transaction to the mempool with a timestamp.
Sourcefn mempool_tx(&self, tx_id: [u8; 32]) -> Result<Option<Transaction>>
fn mempool_tx(&self, tx_id: [u8; 32]) -> Result<Option<Transaction>>
Gets a transaction from the mempool.
Sourcefn mempool_tx_exists(&self, tx_id: [u8; 32]) -> Result<bool>
fn mempool_tx_exists(&self, tx_id: [u8; 32]) -> Result<bool>
Checks if a transaction exists in the mempool.
Sourcefn delete_mempool_tx(
&mut self,
tx_id: [u8; 32],
cascade: bool,
) -> Result<Vec<[u8; 32]>>
fn delete_mempool_tx( &mut self, tx_id: [u8; 32], cascade: bool, ) -> Result<Vec<[u8; 32]>>
Deletes a transaction from the mempool.
If cascade is true, all dependant transactions are deleted
Return a vector with all the deleted tx_id
Sourcefn mempool_txs_by_spendable_ids(&self, n: &[SpendingId]) -> HashSet<[u8; 32]>
fn mempool_txs_by_spendable_ids(&self, n: &[SpendingId]) -> HashSet<[u8; 32]>
Get transactions hash from the mempool, searching by spendable ids
Sourcefn mempool_txs_sorted_by_fee(
&self,
) -> Result<Box<dyn Iterator<Item = Transaction> + '_>>
fn mempool_txs_sorted_by_fee( &self, ) -> Result<Box<dyn Iterator<Item = Transaction> + '_>>
Get an iterator over the mempool transactions sorted by gas price
Sourcefn mempool_txs_ids_sorted_by_fee(
&self,
) -> Result<Box<dyn Iterator<Item = (u64, [u8; 32])> + '_>>
fn mempool_txs_ids_sorted_by_fee( &self, ) -> Result<Box<dyn Iterator<Item = (u64, [u8; 32])> + '_>>
Get an iterator over the mempool transactions hash by gas price
Sourcefn mempool_txs_ids_sorted_by_low_fee(
&self,
) -> Result<Box<dyn Iterator<Item = (u64, [u8; 32])> + '_>>
fn mempool_txs_ids_sorted_by_low_fee( &self, ) -> Result<Box<dyn Iterator<Item = (u64, [u8; 32])> + '_>>
Get an iterator over the mempool transactions hash by gas price (asc)
Sourcefn mempool_expired_txs(&self, timestamp: u64) -> Result<Vec<[u8; 32]>>
fn mempool_expired_txs(&self, timestamp: u64) -> Result<Vec<[u8; 32]>>
Get all expired transactions.
Sourcefn mempool_txs_count(&self) -> usize
fn mempool_txs_count(&self) -> usize
Number of persisted transactions