refactor(txpool): simplify is local (#87)

This commit is contained in:
Matthias Seitz
2022-10-17 20:43:27 +02:00
committed by GitHub
parent 6bc09809f3
commit 522a4e689e
4 changed files with 6 additions and 7 deletions

View File

@ -179,7 +179,6 @@ where
transaction,
transaction_id,
propagate: false,
is_local: false,
timestamp: Instant::now(),
origin,
};

View File

@ -19,7 +19,6 @@ bitflags::bitflags! {
///
/// Set to 1 if `feeCap` of the transaction meets the requirement of the pending block.
const ENOUGH_FEE_CAP_BLOCK = 0b000010;
const IS_LOCAL = 0b000001;
const PENDING_POOL_BITS = Self::NO_PARKED_ANCESTORS.bits | Self::NO_NONCE_GAPS.bits | Self::ENOUGH_BALANCE.bits | Self::NOT_TOO_MUCH_GAS.bits | Self::ENOUGH_FEE_CAP_BLOCK.bits;
@ -112,7 +111,7 @@ mod tests {
assert_eq!(SubPool::Pending, state.into());
assert!(state.is_pending());
let bits = 0b111111;
let bits = 0b111110;
let state = TxState::from_bits(bits).unwrap();
assert_eq!(SubPool::Pending, state.into());
assert!(state.is_pending());

View File

@ -355,7 +355,6 @@ impl MockTransactionFactory {
let transaction_id = self.tx_id(&transaction);
MockValidTx {
propagate: false,
is_local: false,
transaction_id,
cost: transaction.cost(),
transaction,

View File

@ -51,8 +51,6 @@ pub struct ValidPoolTransaction<T: PoolTransaction> {
pub transaction_id: TransactionId,
/// Whether to propagate the transaction.
pub propagate: bool,
/// Whether the tx is from a local source.
pub is_local: bool,
/// Total cost of the transaction: `feeCap x gasLimit + transferred_value`.
pub cost: U256,
/// Timestamp when this was added to the pool.
@ -103,6 +101,11 @@ impl<T: PoolTransaction> ValidPoolTransaction<T> {
pub(crate) fn is_underpriced(&self, other: &Self) -> bool {
self.transaction.effective_gas_price() <= other.transaction.effective_gas_price()
}
/// Whether the transaction originated locally.
pub(crate) fn is_local(&self) -> bool {
self.origin.is_local()
}
}
#[cfg(test)]
@ -112,7 +115,6 @@ impl<T: PoolTransaction + Clone> Clone for ValidPoolTransaction<T> {
transaction: self.transaction.clone(),
transaction_id: self.transaction_id,
propagate: self.propagate,
is_local: self.is_local,
cost: self.cost,
timestamp: self.timestamp,
origin: self.origin,