pub struct Mempool { /* private fields */ }Expand description
Simple mempool: FIFO queue with deduplication
Implementations§
Source§impl Mempool
impl Mempool
pub fn new(max_size: usize, max_tx_bytes: usize) -> Self
Sourcepub async fn add_tx(&self, tx: Vec<u8>) -> bool
pub async fn add_tx(&self, tx: Vec<u8>) -> bool
Add a transaction to the mempool. Returns false if rejected.
Sourcepub async fn collect_payload(&self, max_bytes: usize) -> Vec<u8> ⓘ
pub async fn collect_payload(&self, max_bytes: usize) -> Vec<u8> ⓘ
Collect transactions for a block proposal (up to max_bytes total).
Collected transactions are removed from the pool.
The payload is length-prefixed: [u32_le len][bytes]...
Sourcepub fn decode_payload(payload: &[u8]) -> Vec<Vec<u8>>
pub fn decode_payload(payload: &[u8]) -> Vec<Vec<u8>>
Reap collected payload back into individual transactions
pub async fn size(&self) -> usize
Trait Implementations§
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