Trait Mempool

Source
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§

Source

fn store_mempool_tx(&mut self, tx: &Transaction, timestamp: u64) -> Result<()>

Adds a transaction to the mempool with a timestamp.

Source

fn mempool_tx(&self, tx_id: [u8; 32]) -> Result<Option<Transaction>>

Gets a transaction from the mempool.

Source

fn mempool_tx_exists(&self, tx_id: [u8; 32]) -> Result<bool>

Checks if a transaction exists in the mempool.

Source

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

Source

fn mempool_txs_by_spendable_ids(&self, n: &[SpendingId]) -> HashSet<[u8; 32]>

Get transactions hash from the mempool, searching by spendable ids

Source

fn mempool_txs_sorted_by_fee( &self, ) -> Result<Box<dyn Iterator<Item = Transaction> + '_>>

Get an iterator over the mempool transactions sorted by gas price

Source

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

Source

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)

Source

fn mempool_txs_ids(&self) -> Result<Vec<[u8; 32]>>

Get all transactions hashes.

Source

fn mempool_expired_txs(&self, timestamp: u64) -> Result<Vec<[u8; 32]>>

Get all expired transactions.

Source

fn mempool_txs_count(&self) -> usize

Number of persisted transactions

Implementors§

Source§

impl<'db, DB: DBAccess> Mempool for DBTransaction<'db, DB>