pub struct Mempool { /* private fields */ }Expand description
Pending transaction pool
Implementations§
Source§impl Mempool
impl Mempool
pub fn new(max_size: usize, min_fee: u64) -> Mempool
pub fn set_path(&self, path: &str)
pub fn load_from_file(&self, path: &str)
pub fn save_to_file(&self) -> Result<(), String>
pub fn is_modified(&self) -> bool
Sourcepub async fn submit(
&self,
tx: TransferTransaction,
ledger: &RwLock<Ledger>,
) -> Result<[u8; 32], TxError>
pub async fn submit( &self, tx: TransferTransaction, ledger: &RwLock<Ledger>, ) -> Result<[u8; 32], TxError>
Submit a transaction to the mempool after validation.
Uses RwLock::read() for non-blocking reads since this is called from async context.
Sourcepub fn drain_for_block(
&self,
max_count: usize,
min_fee: u64,
) -> Vec<TransferTransaction>
pub fn drain_for_block( &self, max_count: usize, min_fee: u64, ) -> Vec<TransferTransaction>
Drain highest-fee transactions for block inclusion
Sourcepub fn remove(&self, tx_hashes: &[[u8; 32]])
pub fn remove(&self, tx_hashes: &[[u8; 32]])
Remove confirmed transactions (after block acceptance)
Sourcepub fn revalidate(&self, ledger: &RwLock<Ledger>)
pub fn revalidate(&self, ledger: &RwLock<Ledger>)
Revalidate all pending txs against current ledger state
pub fn pending(&self) -> Vec<TransferTransaction>
pub fn hashes(&self) -> Vec<[u8; 32]>
pub fn get_tx(&self, hash: &[u8; 32]) -> Option<TransferTransaction>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl !Freeze for Mempool
impl RefUnwindSafe for Mempool
impl Send for Mempool
impl Sync for Mempool
impl Unpin for Mempool
impl UnsafeUnpin 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