pub struct MemPool { /* private fields */ }Implementations§
Source§impl MemPool
impl MemPool
pub fn new() -> Self
Sourcepub fn start_expiry_watchdog(
&self,
on_expiry: impl FnMut(TransactionId) + Send + Sync + 'static,
)
pub fn start_expiry_watchdog( &self, on_expiry: impl FnMut(TransactionId) + Send + Sync + 'static, )
Starts a background task that removes expired transactions
Sourcepub async fn get_mempool(&self) -> Vec<Transaction>
pub async fn get_mempool(&self) -> Vec<Transaction>
Get a vector of all transactions in this mempool
Sourcepub async fn add_transaction(&self, transaction: Transaction)
pub async fn add_transaction(&self, transaction: Transaction)
Add a transaction to the mempool WARNING: Make sure this transaction is valid before
Sourcepub async fn validate_transaction(&self, transaction: &Transaction) -> bool
pub async fn validate_transaction(&self, transaction: &Transaction) -> bool
Returns true if a transaction is valid (check for double spending)
Sourcepub async fn spend_transactions(&self, transactions: Vec<TransactionId>)
pub async fn spend_transactions(&self, transactions: Vec<TransactionId>)
Remove transactions that have been spent
pub async fn mempool_size(&self) -> usize
Auto Trait Implementations§
impl Freeze for MemPool
impl !RefUnwindSafe for MemPool
impl Send for MemPool
impl Sync for MemPool
impl Unpin for MemPool
impl !UnwindSafe for MemPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more