Struct cfx_packing_pool::PackingBatch
source · pub struct PackingBatch<TX: PackingPoolTransaction> { /* private fields */ }
Expand description
A batch of transactions that have the same sender and continuous nonces.
PackingBatch
is designed to group transactions from the same sender that
can be packed into the same block. This struct ensures that all transactions
in the batch have the same sender and their nonces form a continuous
sequence.
Implementations§
source§impl<TX: PackingPoolTransaction> PackingBatch<TX>
impl<TX: PackingPoolTransaction> PackingBatch<TX>
pub fn new(tx: TX) -> Self
pub fn sender(&self) -> TX::Sender
pub fn start_nonce(&self) -> U256
pub fn first_gas_price(&self) -> U256
pub fn total_gas_limit(&self) -> U256
pub fn len(&self) -> usize
sourcepub fn insert(
&mut self,
tx: TX,
config: &PackingPoolConfig
) -> (Vec<TX>, Result<(), InsertError>)
pub fn insert( &mut self, tx: TX, config: &PackingPoolConfig ) -> (Vec<TX>, Result<(), InsertError>)
Inserts a transaction into the pool according to PackingPoolConfig
,
without violating the assumptions of PackingBatch
.
§Returns
Returns a tuple consisting of:
- A vector of transactions that were replaced by the insertion. This can be empty if no transactions were displaced.
- A result indicating the success or failure of the insertion operation.
sourcepub fn split_off_suffix(&mut self, index: usize) -> Result<Vec<TX>, RemoveError>
pub fn split_off_suffix(&mut self, index: usize) -> Result<Vec<TX>, RemoveError>
Removes transactions starting from the specified index (included) and returns them.
sourcepub fn split_off_prefix(&mut self, index: usize) -> Result<Vec<TX>, RemoveError>
pub fn split_off_prefix(&mut self, index: usize) -> Result<Vec<TX>, RemoveError>
Removes transactions ending at the specified index (not included) and returns them.
sourcepub fn split_off_by_nonce(
&mut self,
nonce: &U256,
keep_prefix: bool
) -> Result<Vec<TX>, RemoveError>
pub fn split_off_by_nonce( &mut self, nonce: &U256, keep_prefix: bool ) -> Result<Vec<TX>, RemoveError>
Split transactions at the specified nonce (the specified one is in the
past half). Retains a half according to keep_prefix
and returns the
rest half.
Trait Implementations§
source§impl<TX: Clone + PackingPoolTransaction> Clone for PackingBatch<TX>
impl<TX: Clone + PackingPoolTransaction> Clone for PackingBatch<TX>
source§fn clone(&self) -> PackingBatch<TX>
fn clone(&self) -> PackingBatch<TX>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<TX: Debug + PackingPoolTransaction> Debug for PackingBatch<TX>
impl<TX: Debug + PackingPoolTransaction> Debug for PackingBatch<TX>
source§impl<TX: Default + PackingPoolTransaction> Default for PackingBatch<TX>
impl<TX: Default + PackingPoolTransaction> Default for PackingBatch<TX>
source§fn default() -> PackingBatch<TX>
fn default() -> PackingBatch<TX>
source§impl<TX> MallocSizeOf for PackingBatch<TX>where
TX: MallocSizeOf + PackingPoolTransaction,
impl<TX> MallocSizeOf for PackingBatch<TX>where
TX: MallocSizeOf + PackingPoolTransaction,
source§impl<TX: PartialEq + PackingPoolTransaction> PartialEq for PackingBatch<TX>
impl<TX: PartialEq + PackingPoolTransaction> PartialEq for PackingBatch<TX>
source§fn eq(&self, other: &PackingBatch<TX>) -> bool
fn eq(&self, other: &PackingBatch<TX>) -> bool
self
and other
values to be equal, and is used
by ==
.