add use_self clippy lint (#8325)

This commit is contained in:
Thomas Coratger
2024-05-29 15:14:14 +02:00
committed by GitHub
parent 0cb5358fef
commit 19c529e8df
200 changed files with 1817 additions and 1954 deletions

View File

@ -405,7 +405,7 @@ pub enum DiskFileBlobStoreError {
impl From<DiskFileBlobStoreError> for BlobStoreError {
fn from(value: DiskFileBlobStoreError) -> Self {
BlobStoreError::Other(Box::new(value))
Self::Other(Box::new(value))
}
}

View File

@ -216,7 +216,7 @@ impl InvalidPoolTransactionError {
#[inline]
fn is_bad_transaction(&self) -> bool {
match self {
InvalidPoolTransactionError::Consensus(err) => {
Self::Consensus(err) => {
// transaction considered invalid by the consensus rules
// We do not consider the following errors to be erroneous transactions, since they
// depend on dynamic environmental conditions and should not be assumed to have been
@ -250,17 +250,17 @@ impl InvalidPoolTransactionError {
InvalidTransactionError::SignerAccountHasBytecode => true,
}
}
InvalidPoolTransactionError::ExceedsGasLimit(_, _) => true,
InvalidPoolTransactionError::ExceedsMaxInitCodeSize(_, _) => true,
InvalidPoolTransactionError::OversizedData(_, _) => true,
InvalidPoolTransactionError::Underpriced => {
Self::ExceedsGasLimit(_, _) => true,
Self::ExceedsMaxInitCodeSize(_, _) => true,
Self::OversizedData(_, _) => true,
Self::Underpriced => {
// local setting
false
}
InvalidPoolTransactionError::IntrinsicGasTooLow => true,
InvalidPoolTransactionError::Overdraft => false,
InvalidPoolTransactionError::Other(err) => err.is_bad_transaction(),
InvalidPoolTransactionError::Eip4844(eip4844_err) => {
Self::IntrinsicGasTooLow => true,
Self::Overdraft => false,
Self::Other(err) => err.is_bad_transaction(),
Self::Eip4844(eip4844_err) => {
match eip4844_err {
Eip4844PoolTransactionError::MissingEip4844BlobSidecar => {
// this is only reachable when blob transactions are reinjected and we're
@ -291,12 +291,7 @@ impl InvalidPoolTransactionError {
/// Returns `true` if an import failed due to nonce gap.
pub const fn is_nonce_gap(&self) -> bool {
matches!(
self,
InvalidPoolTransactionError::Consensus(InvalidTransactionError::NonceNotConsistent)
) || matches!(
self,
InvalidPoolTransactionError::Eip4844(Eip4844PoolTransactionError::Eip4844NonceGap)
)
matches!(self, Self::Consensus(InvalidTransactionError::NonceNotConsistent)) ||
matches!(self, Self::Eip4844(Eip4844PoolTransactionError::Eip4844NonceGap))
}
}

View File

@ -65,7 +65,7 @@ impl SenderId {
impl From<u64> for SenderId {
fn from(value: u64) -> Self {
SenderId(value)
Self(value)
}
}
@ -93,11 +93,7 @@ impl TransactionId {
///
/// This returns `transaction_nonce - 1` if `transaction_nonce` is higher than the
/// `on_chain_nonce`
pub fn ancestor(
transaction_nonce: u64,
on_chain_nonce: u64,
sender: SenderId,
) -> Option<TransactionId> {
pub fn ancestor(transaction_nonce: u64, on_chain_nonce: u64, sender: SenderId) -> Option<Self> {
if transaction_nonce == on_chain_nonce {
return None
}
@ -106,13 +102,13 @@ impl TransactionId {
}
/// Returns the `TransactionId` that would come before this transaction.
pub(crate) fn unchecked_ancestor(&self) -> Option<TransactionId> {
(self.nonce != 0).then(|| TransactionId::new(self.sender, self.nonce - 1))
pub(crate) fn unchecked_ancestor(&self) -> Option<Self> {
(self.nonce != 0).then(|| Self::new(self.sender, self.nonce - 1))
}
/// Returns the `TransactionId` that directly follows this transaction: `self.nonce + 1`
pub const fn descendant(&self) -> TransactionId {
TransactionId::new(self.sender, self.nonce + 1)
pub const fn descendant(&self) -> Self {
Self::new(self.sender, self.nonce + 1)
}
/// Returns the nonce that follows immediately after this one.

View File

@ -485,7 +485,7 @@ impl MaintainedPoolState {
/// Returns `true` if the pool is assumed to be out of sync with the current state.
#[inline]
const fn is_drifted(&self) -> bool {
matches!(self, MaintainedPoolState::Drifted)
matches!(self, Self::Drifted)
}
}

View File

@ -15,7 +15,7 @@ pub enum Priority<T: Ord + Clone> {
impl<T: Ord + Clone> From<Option<T>> for Priority<T> {
fn from(value: Option<T>) -> Self {
value.map_or(Priority::None, Priority::Value)
value.map_or(Self::None, Priority::Value)
}
}

View File

@ -148,7 +148,7 @@ impl<T: TransactionOrdering> BestTransactions<T> {
impl<T: TransactionOrdering> crate::traits::BestTransactions for BestTransactions<T> {
fn mark_invalid(&mut self, tx: &Self::Item) {
BestTransactions::mark_invalid(self, tx)
Self::mark_invalid(self, tx)
}
fn no_updates(&mut self) {

View File

@ -80,11 +80,6 @@ impl TransactionEvent {
/// Returns `true` if the event is final and no more events are expected for this transaction
/// hash.
pub const fn is_final(&self) -> bool {
matches!(
self,
TransactionEvent::Replaced(_) |
TransactionEvent::Mined(_) |
TransactionEvent::Discarded
)
matches!(self, Self::Replaced(_) | Self::Mined(_) | Self::Discarded)
}
}

View File

@ -1023,7 +1023,7 @@ impl<T: PoolTransaction> AddedTransaction<T> {
/// Returns whether the transaction has been added to the pending pool.
pub(crate) const fn as_pending(&self) -> Option<&AddedPendingTransaction<T>> {
match self {
AddedTransaction::Pending(tx) => Some(tx),
Self::Pending(tx) => Some(tx),
_ => None,
}
}
@ -1031,16 +1031,16 @@ impl<T: PoolTransaction> AddedTransaction<T> {
/// Returns the replaced transaction if there was one
pub(crate) const fn replaced(&self) -> Option<&Arc<ValidPoolTransaction<T>>> {
match self {
AddedTransaction::Pending(tx) => tx.replaced.as_ref(),
AddedTransaction::Parked { replaced, .. } => replaced.as_ref(),
Self::Pending(tx) => tx.replaced.as_ref(),
Self::Parked { replaced, .. } => replaced.as_ref(),
}
}
/// Returns the discarded transactions if there were any
pub(crate) fn discarded_transactions(&self) -> Option<&[Arc<ValidPoolTransaction<T>>]> {
match self {
AddedTransaction::Pending(tx) => Some(&tx.discarded),
AddedTransaction::Parked { .. } => None,
Self::Pending(tx) => Some(&tx.discarded),
Self::Parked { .. } => None,
}
}
@ -1052,18 +1052,18 @@ impl<T: PoolTransaction> AddedTransaction<T> {
/// Returns the hash of the transaction
pub(crate) fn hash(&self) -> &TxHash {
match self {
AddedTransaction::Pending(tx) => tx.transaction.hash(),
AddedTransaction::Parked { transaction, .. } => transaction.hash(),
Self::Pending(tx) => tx.transaction.hash(),
Self::Parked { transaction, .. } => transaction.hash(),
}
}
/// Converts this type into the event type for listeners
pub(crate) fn into_new_transaction_event(self) -> NewTransactionEvent<T> {
match self {
AddedTransaction::Pending(tx) => {
Self::Pending(tx) => {
NewTransactionEvent { subpool: SubPool::Pending, transaction: tx.transaction }
}
AddedTransaction::Parked { transaction, subpool, .. } => {
Self::Parked { transaction, subpool, .. } => {
NewTransactionEvent { transaction, subpool }
}
}
@ -1073,8 +1073,8 @@ impl<T: PoolTransaction> AddedTransaction<T> {
#[cfg(test)]
pub(crate) const fn subpool(&self) -> SubPool {
match self {
AddedTransaction::Pending(_) => SubPool::Pending,
AddedTransaction::Parked { subpool, .. } => *subpool,
Self::Pending(_) => SubPool::Pending,
Self::Parked { subpool, .. } => *subpool,
}
}
@ -1082,8 +1082,8 @@ impl<T: PoolTransaction> AddedTransaction<T> {
#[cfg(test)]
pub(crate) fn id(&self) -> &TransactionId {
match self {
AddedTransaction::Pending(added) => added.transaction.id(),
AddedTransaction::Parked { transaction, .. } => transaction.id(),
Self::Pending(added) => added.transaction.id(),
Self::Parked { transaction, .. } => transaction.id(),
}
}
}

View File

@ -31,6 +31,6 @@ impl SubAssign<usize> for SizeTracker {
impl From<SizeTracker> for usize {
fn from(value: SizeTracker) -> Self {
value.0 as usize
value.0 as Self
}
}

View File

@ -56,19 +56,19 @@ impl TxState {
/// - enough blob fee cap
#[inline]
pub(crate) const fn is_pending(&self) -> bool {
self.bits() >= TxState::PENDING_POOL_BITS.bits()
self.bits() >= Self::PENDING_POOL_BITS.bits()
}
/// Whether this transaction is a blob transaction.
#[inline]
pub(crate) const fn is_blob(&self) -> bool {
self.contains(TxState::BLOB_TRANSACTION)
self.contains(Self::BLOB_TRANSACTION)
}
/// Returns `true` if the transaction has a nonce gap.
#[inline]
pub(crate) const fn has_nonce_gap(&self) -> bool {
!self.intersects(TxState::NO_NONCE_GAPS)
!self.intersects(Self::NO_NONCE_GAPS)
}
}
@ -95,30 +95,30 @@ impl SubPool {
/// Whether this transaction is to be moved to the pending sub-pool.
#[inline]
pub const fn is_pending(&self) -> bool {
matches!(self, SubPool::Pending)
matches!(self, Self::Pending)
}
/// Whether this transaction is in the queued pool.
#[inline]
pub const fn is_queued(&self) -> bool {
matches!(self, SubPool::Queued)
matches!(self, Self::Queued)
}
/// Whether this transaction is in the base fee pool.
#[inline]
pub const fn is_base_fee(&self) -> bool {
matches!(self, SubPool::BaseFee)
matches!(self, Self::BaseFee)
}
/// Whether this transaction is in the blob pool.
#[inline]
pub const fn is_blob(&self) -> bool {
matches!(self, SubPool::Blob)
matches!(self, Self::Blob)
}
/// Returns whether this is a promotion depending on the current sub-pool location.
#[inline]
pub fn is_promoted(&self, other: SubPool) -> bool {
pub fn is_promoted(&self, other: Self) -> bool {
self > &other
}
}
@ -126,16 +126,16 @@ impl SubPool {
impl From<TxState> for SubPool {
fn from(value: TxState) -> Self {
if value.is_pending() {
return SubPool::Pending
return Self::Pending
}
if value.is_blob() {
// all _non-pending_ blob transactions are in the blob sub-pool
return SubPool::Blob
return Self::Blob
}
if value.bits() < TxState::BASE_FEE_POOL_BITS.bits() {
return SubPool::Queued
return Self::Queued
}
SubPool::BaseFee
Self::BaseFee
}
}

View File

@ -1704,7 +1704,7 @@ pub(crate) struct PendingFees {
impl Default for PendingFees {
fn default() -> Self {
PendingFees { base_fee: Default::default(), blob_fee: BLOB_TX_MIN_BLOB_GASPRICE }
Self { base_fee: Default::default(), blob_fee: BLOB_TX_MIN_BLOB_GASPRICE }
}
}

View File

@ -142,7 +142,7 @@ pub struct TransactionBuilder {
impl TransactionBuilder {
/// Converts the transaction builder into a legacy transaction format.
pub fn into_legacy(self) -> TransactionSigned {
TransactionBuilder::signed(
Self::signed(
TxLegacy {
chain_id: Some(self.chain_id),
nonce: self.nonce,
@ -159,7 +159,7 @@ impl TransactionBuilder {
/// Converts the transaction builder into a transaction format using EIP-1559.
pub fn into_eip1559(self) -> TransactionSigned {
TransactionBuilder::signed(
Self::signed(
TxEip1559 {
chain_id: self.chain_id,
nonce: self.nonce,
@ -177,7 +177,7 @@ impl TransactionBuilder {
}
/// Converts the transaction builder into a transaction format using EIP-4844.
pub fn into_eip4844(self) -> TransactionSigned {
TransactionBuilder::signed(
Self::signed(
TxEip4844 {
chain_id: self.chain_id,
nonce: self.nonce,

View File

@ -218,7 +218,7 @@ impl MockTransaction {
/// Returns a new legacy transaction with random address and hash and empty values
pub fn legacy() -> Self {
MockTransaction::Legacy {
Self::Legacy {
chain_id: Some(1),
hash: B256::random(),
sender: Address::random(),
@ -234,7 +234,7 @@ impl MockTransaction {
/// Returns a new EIP2930 transaction with random address and hash and empty values
pub fn eip2930() -> Self {
MockTransaction::Eip2930 {
Self::Eip2930 {
chain_id: 1,
hash: B256::random(),
sender: Address::random(),
@ -251,7 +251,7 @@ impl MockTransaction {
/// Returns a new EIP1559 transaction with random address and hash and empty values
pub fn eip1559() -> Self {
MockTransaction::Eip1559 {
Self::Eip1559 {
chain_id: 1,
hash: B256::random(),
sender: Address::random(),
@ -269,7 +269,7 @@ impl MockTransaction {
/// Returns a new EIP4844 transaction with random address and hash and empty values
pub fn eip4844() -> Self {
MockTransaction::Eip4844 {
Self::Eip4844 {
chain_id: 1,
hash: B256::random(),
sender: Address::random(),
@ -291,8 +291,7 @@ impl MockTransaction {
/// Returns a new EIP4844 transaction with a provided sidecar
pub fn eip4844_with_sidecar(sidecar: BlobTransactionSidecar) -> Self {
let mut transaction = Self::eip4844();
if let MockTransaction::Eip4844 { sidecar: ref mut existing_sidecar, .. } = &mut transaction
{
if let Self::Eip4844 { sidecar: ref mut existing_sidecar, .. } = &mut transaction {
*existing_sidecar = sidecar;
}
transaction
@ -326,7 +325,7 @@ impl MockTransaction {
/// Sets the max fee per blob gas for EIP-4844 transactions,
pub fn set_blob_fee(&mut self, val: u128) -> &mut Self {
if let MockTransaction::Eip4844 { max_fee_per_blob_gas, .. } = self {
if let Self::Eip4844 { max_fee_per_blob_gas, .. } = self {
*max_fee_per_blob_gas = val;
}
self
@ -334,8 +333,8 @@ impl MockTransaction {
/// Sets the priority fee for dynamic fee transactions (EIP-1559 and EIP-4844)
pub fn set_priority_fee(&mut self, val: u128) -> &mut Self {
if let MockTransaction::Eip1559 { max_priority_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_priority_fee_per_gas, .. } = self
if let Self::Eip1559 { max_priority_fee_per_gas, .. } |
Self::Eip4844 { max_priority_fee_per_gas, .. } = self
{
*max_priority_fee_per_gas = val;
}
@ -351,18 +350,15 @@ impl MockTransaction {
/// Gets the priority fee for dynamic fee transactions (EIP-1559 and EIP-4844)
pub const fn get_priority_fee(&self) -> Option<u128> {
match self {
MockTransaction::Eip1559 { max_priority_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_priority_fee_per_gas, .. } => {
Some(*max_priority_fee_per_gas)
}
Self::Eip1559 { max_priority_fee_per_gas, .. } |
Self::Eip4844 { max_priority_fee_per_gas, .. } => Some(*max_priority_fee_per_gas),
_ => None,
}
}
/// Sets the max fee for dynamic fee transactions (EIP-1559 and EIP-4844)
pub fn set_max_fee(&mut self, val: u128) -> &mut Self {
if let MockTransaction::Eip1559 { max_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_fee_per_gas, .. } = self
if let Self::Eip1559 { max_fee_per_gas, .. } | Self::Eip4844 { max_fee_per_gas, .. } = self
{
*max_fee_per_gas = val;
}
@ -378,8 +374,9 @@ impl MockTransaction {
/// Gets the max fee for dynamic fee transactions (EIP-1559 and EIP-4844)
pub const fn get_max_fee(&self) -> Option<u128> {
match self {
MockTransaction::Eip1559 { max_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_fee_per_gas, .. } => Some(*max_fee_per_gas),
Self::Eip1559 { max_fee_per_gas, .. } | Self::Eip4844 { max_fee_per_gas, .. } => {
Some(*max_fee_per_gas)
}
_ => None,
}
}
@ -387,10 +384,10 @@ impl MockTransaction {
/// Sets the access list for transactions supporting EIP-1559, EIP-4844, and EIP-2930.
pub fn set_accesslist(&mut self, list: AccessList) -> &mut Self {
match self {
MockTransaction::Legacy { .. } => {}
MockTransaction::Eip1559 { access_list: accesslist, .. } |
MockTransaction::Eip4844 { access_list: accesslist, .. } |
MockTransaction::Eip2930 { access_list: accesslist, .. } => {
Self::Legacy { .. } => {}
Self::Eip1559 { access_list: accesslist, .. } |
Self::Eip4844 { access_list: accesslist, .. } |
Self::Eip2930 { access_list: accesslist, .. } => {
*accesslist = list;
}
}
@ -400,12 +397,11 @@ impl MockTransaction {
/// Sets the gas price for the transaction.
pub fn set_gas_price(&mut self, val: u128) -> &mut Self {
match self {
MockTransaction::Legacy { gas_price, .. } |
MockTransaction::Eip2930 { gas_price, .. } => {
Self::Legacy { gas_price, .. } | Self::Eip2930 { gas_price, .. } => {
*gas_price = val;
}
MockTransaction::Eip1559 { max_fee_per_gas, max_priority_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_fee_per_gas, max_priority_fee_per_gas, .. } => {
Self::Eip1559 { max_fee_per_gas, max_priority_fee_per_gas, .. } |
Self::Eip4844 { max_fee_per_gas, max_priority_fee_per_gas, .. } => {
*max_fee_per_gas = val;
*max_priority_fee_per_gas = val;
}
@ -416,20 +412,11 @@ impl MockTransaction {
/// Sets the gas price for the transaction.
pub fn with_gas_price(mut self, val: u128) -> Self {
match self {
MockTransaction::Legacy { ref mut gas_price, .. } |
MockTransaction::Eip2930 { ref mut gas_price, .. } => {
Self::Legacy { ref mut gas_price, .. } | Self::Eip2930 { ref mut gas_price, .. } => {
*gas_price = val;
}
MockTransaction::Eip1559 {
ref mut max_fee_per_gas,
ref mut max_priority_fee_per_gas,
..
} |
MockTransaction::Eip4844 {
ref mut max_fee_per_gas,
ref mut max_priority_fee_per_gas,
..
} => {
Self::Eip1559 { ref mut max_fee_per_gas, ref mut max_priority_fee_per_gas, .. } |
Self::Eip4844 { ref mut max_fee_per_gas, ref mut max_priority_fee_per_gas, .. } => {
*max_fee_per_gas = val;
*max_priority_fee_per_gas = val;
}
@ -440,10 +427,10 @@ impl MockTransaction {
/// Gets the gas price for the transaction.
pub const fn get_gas_price(&self) -> u128 {
match self {
MockTransaction::Legacy { gas_price, .. } |
MockTransaction::Eip2930 { gas_price, .. } => *gas_price,
MockTransaction::Eip1559 { max_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_fee_per_gas, .. } => *max_fee_per_gas,
Self::Legacy { gas_price, .. } | Self::Eip2930 { gas_price, .. } => *gas_price,
Self::Eip1559 { max_fee_per_gas, .. } | Self::Eip4844 { max_fee_per_gas, .. } => {
*max_fee_per_gas
}
}
}
@ -515,7 +502,7 @@ impl MockTransaction {
/// If it's an EIP-4844 transaction.
pub fn inc_blob_fee_by(&self, value: u128) -> Self {
let mut this = self.clone();
if let MockTransaction::Eip4844 { max_fee_per_blob_gas, .. } = &mut this {
if let Self::Eip4844 { max_fee_per_blob_gas, .. } = &mut this {
*max_fee_per_blob_gas = max_fee_per_blob_gas.checked_add(value).unwrap();
}
this
@ -533,7 +520,7 @@ impl MockTransaction {
/// If it's an EIP-4844 transaction.
pub fn decr_blob_fee_by(&self, value: u128) -> Self {
let mut this = self.clone();
if let MockTransaction::Eip4844 { max_fee_per_blob_gas, .. } = &mut this {
if let Self::Eip4844 { max_fee_per_blob_gas, .. } = &mut this {
*max_fee_per_blob_gas = max_fee_per_blob_gas.checked_sub(value).unwrap();
}
this
@ -551,61 +538,61 @@ impl MockTransaction {
/// Checks if the transaction is of the legacy type.
pub const fn is_legacy(&self) -> bool {
matches!(self, MockTransaction::Legacy { .. })
matches!(self, Self::Legacy { .. })
}
/// Checks if the transaction is of the EIP-1559 type.
pub const fn is_eip1559(&self) -> bool {
matches!(self, MockTransaction::Eip1559 { .. })
matches!(self, Self::Eip1559 { .. })
}
/// Checks if the transaction is of the EIP-4844 type.
pub const fn is_eip4844(&self) -> bool {
matches!(self, MockTransaction::Eip4844 { .. })
matches!(self, Self::Eip4844 { .. })
}
/// Checks if the transaction is of the EIP-2930 type.
pub const fn is_eip2930(&self) -> bool {
matches!(self, MockTransaction::Eip2930 { .. })
matches!(self, Self::Eip2930 { .. })
}
}
impl PoolTransaction for MockTransaction {
fn hash(&self) -> &TxHash {
match self {
MockTransaction::Legacy { hash, .. } |
MockTransaction::Eip1559 { hash, .. } |
MockTransaction::Eip4844 { hash, .. } |
MockTransaction::Eip2930 { hash, .. } => hash,
Self::Legacy { hash, .. } |
Self::Eip1559 { hash, .. } |
Self::Eip4844 { hash, .. } |
Self::Eip2930 { hash, .. } => hash,
}
}
fn sender(&self) -> Address {
match self {
MockTransaction::Legacy { sender, .. } |
MockTransaction::Eip1559 { sender, .. } |
MockTransaction::Eip4844 { sender, .. } |
MockTransaction::Eip2930 { sender, .. } => *sender,
Self::Legacy { sender, .. } |
Self::Eip1559 { sender, .. } |
Self::Eip4844 { sender, .. } |
Self::Eip2930 { sender, .. } => *sender,
}
}
fn nonce(&self) -> u64 {
match self {
MockTransaction::Legacy { nonce, .. } |
MockTransaction::Eip1559 { nonce, .. } |
MockTransaction::Eip4844 { nonce, .. } |
MockTransaction::Eip2930 { nonce, .. } => *nonce,
Self::Legacy { nonce, .. } |
Self::Eip1559 { nonce, .. } |
Self::Eip4844 { nonce, .. } |
Self::Eip2930 { nonce, .. } => *nonce,
}
}
fn cost(&self) -> U256 {
match self {
MockTransaction::Legacy { gas_price, value, gas_limit, .. } |
MockTransaction::Eip2930 { gas_limit, gas_price, value, .. } => {
Self::Legacy { gas_price, value, gas_limit, .. } |
Self::Eip2930 { gas_limit, gas_price, value, .. } => {
U256::from(*gas_limit) * U256::from(*gas_price) + *value
}
MockTransaction::Eip1559 { max_fee_per_gas, value, gas_limit, .. } |
MockTransaction::Eip4844 { max_fee_per_gas, value, gas_limit, .. } => {
Self::Eip1559 { max_fee_per_gas, value, gas_limit, .. } |
Self::Eip4844 { max_fee_per_gas, value, gas_limit, .. } => {
U256::from(*gas_limit) * U256::from(*max_fee_per_gas) + *value
}
}
@ -617,35 +604,33 @@ impl PoolTransaction for MockTransaction {
fn max_fee_per_gas(&self) -> u128 {
match self {
MockTransaction::Legacy { gas_price, .. } |
MockTransaction::Eip2930 { gas_price, .. } => *gas_price,
MockTransaction::Eip1559 { max_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_fee_per_gas, .. } => *max_fee_per_gas,
Self::Legacy { gas_price, .. } | Self::Eip2930 { gas_price, .. } => *gas_price,
Self::Eip1559 { max_fee_per_gas, .. } | Self::Eip4844 { max_fee_per_gas, .. } => {
*max_fee_per_gas
}
}
}
fn access_list(&self) -> Option<&AccessList> {
match self {
MockTransaction::Legacy { .. } => None,
MockTransaction::Eip1559 { access_list: accesslist, .. } |
MockTransaction::Eip4844 { access_list: accesslist, .. } |
MockTransaction::Eip2930 { access_list: accesslist, .. } => Some(accesslist),
Self::Legacy { .. } => None,
Self::Eip1559 { access_list: accesslist, .. } |
Self::Eip4844 { access_list: accesslist, .. } |
Self::Eip2930 { access_list: accesslist, .. } => Some(accesslist),
}
}
fn max_priority_fee_per_gas(&self) -> Option<u128> {
match self {
MockTransaction::Legacy { .. } | MockTransaction::Eip2930 { .. } => None,
MockTransaction::Eip1559 { max_priority_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_priority_fee_per_gas, .. } => {
Some(*max_priority_fee_per_gas)
}
Self::Legacy { .. } | Self::Eip2930 { .. } => None,
Self::Eip1559 { max_priority_fee_per_gas, .. } |
Self::Eip4844 { max_priority_fee_per_gas, .. } => Some(*max_priority_fee_per_gas),
}
}
fn max_fee_per_blob_gas(&self) -> Option<u128> {
match self {
MockTransaction::Eip4844 { max_fee_per_blob_gas, .. } => Some(*max_fee_per_blob_gas),
Self::Eip4844 { max_fee_per_blob_gas, .. } => Some(*max_fee_per_blob_gas),
_ => None,
}
}
@ -679,50 +664,47 @@ impl PoolTransaction for MockTransaction {
/// Returns the priority fee or gas price based on the transaction type.
fn priority_fee_or_price(&self) -> u128 {
match self {
MockTransaction::Legacy { gas_price, .. } |
MockTransaction::Eip2930 { gas_price, .. } => *gas_price,
MockTransaction::Eip1559 { max_priority_fee_per_gas, .. } |
MockTransaction::Eip4844 { max_priority_fee_per_gas, .. } => *max_priority_fee_per_gas,
Self::Legacy { gas_price, .. } | Self::Eip2930 { gas_price, .. } => *gas_price,
Self::Eip1559 { max_priority_fee_per_gas, .. } |
Self::Eip4844 { max_priority_fee_per_gas, .. } => *max_priority_fee_per_gas,
}
}
/// Returns the transaction kind associated with the transaction.
fn kind(&self) -> TxKind {
match self {
MockTransaction::Legacy { to, .. } |
MockTransaction::Eip1559 { to, .. } |
MockTransaction::Eip2930 { to, .. } => *to,
MockTransaction::Eip4844 { to, .. } => TxKind::Call(*to),
Self::Legacy { to, .. } | Self::Eip1559 { to, .. } | Self::Eip2930 { to, .. } => *to,
Self::Eip4844 { to, .. } => TxKind::Call(*to),
}
}
/// Returns the input data associated with the transaction.
fn input(&self) -> &[u8] {
match self {
MockTransaction::Legacy { .. } => &[],
MockTransaction::Eip1559 { input, .. } |
MockTransaction::Eip4844 { input, .. } |
MockTransaction::Eip2930 { input, .. } => input,
Self::Legacy { .. } => &[],
Self::Eip1559 { input, .. } |
Self::Eip4844 { input, .. } |
Self::Eip2930 { input, .. } => input,
}
}
/// Returns the size of the transaction.
fn size(&self) -> usize {
match self {
MockTransaction::Legacy { size, .. } |
MockTransaction::Eip1559 { size, .. } |
MockTransaction::Eip4844 { size, .. } |
MockTransaction::Eip2930 { size, .. } => *size,
Self::Legacy { size, .. } |
Self::Eip1559 { size, .. } |
Self::Eip4844 { size, .. } |
Self::Eip2930 { size, .. } => *size,
}
}
/// Returns the transaction type as a byte identifier.
fn tx_type(&self) -> u8 {
match self {
MockTransaction::Legacy { .. } => TxType::Legacy.into(),
MockTransaction::Eip1559 { .. } => TxType::Eip1559.into(),
MockTransaction::Eip4844 { .. } => TxType::Eip4844.into(),
MockTransaction::Eip2930 { .. } => TxType::Eip2930.into(),
Self::Legacy { .. } => TxType::Legacy.into(),
Self::Eip1559 { .. } => TxType::Eip1559.into(),
Self::Eip4844 { .. } => TxType::Eip4844.into(),
Self::Eip2930 { .. } => TxType::Eip2930.into(),
}
}
@ -734,10 +716,10 @@ impl PoolTransaction for MockTransaction {
/// Returns the chain ID associated with the transaction.
fn chain_id(&self) -> Option<u64> {
match self {
MockTransaction::Legacy { chain_id, .. } => *chain_id,
MockTransaction::Eip1559 { chain_id, .. } |
MockTransaction::Eip4844 { chain_id, .. } |
MockTransaction::Eip2930 { chain_id, .. } => Some(*chain_id),
Self::Legacy { chain_id, .. } => *chain_id,
Self::Eip1559 { chain_id, .. } |
Self::Eip4844 { chain_id, .. } |
Self::Eip2930 { chain_id, .. } => Some(*chain_id),
}
}
}
@ -790,7 +772,7 @@ impl TryFromRecoveredTransaction for MockTransaction {
to,
value,
input,
}) => Ok(MockTransaction::Legacy {
}) => Ok(Self::Legacy {
chain_id,
hash,
sender,
@ -811,7 +793,7 @@ impl TryFromRecoveredTransaction for MockTransaction {
value,
input,
access_list,
}) => Ok(MockTransaction::Eip2930 {
}) => Ok(Self::Eip2930 {
chain_id,
hash,
sender,
@ -834,7 +816,7 @@ impl TryFromRecoveredTransaction for MockTransaction {
value,
input,
access_list,
}) => Ok(MockTransaction::Eip1559 {
}) => Ok(Self::Eip1559 {
chain_id,
hash,
sender,
@ -861,7 +843,7 @@ impl TryFromRecoveredTransaction for MockTransaction {
access_list,
blob_versioned_hashes: _,
max_fee_per_blob_gas,
}) => Ok(MockTransaction::Eip4844 {
}) => Ok(Self::Eip4844 {
chain_id,
hash,
sender,
@ -1017,7 +999,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction {
to,
value,
input,
}) => MockTransaction::Legacy {
}) => Self::Legacy {
chain_id: *chain_id,
sender,
hash: tx_hash,
@ -1039,7 +1021,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction {
value,
access_list,
input,
}) => MockTransaction::Eip2930 {
}) => Self::Eip2930 {
chain_id: *chain_id,
sender,
hash: tx_hash,
@ -1062,7 +1044,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction {
value,
input,
access_list,
}) => MockTransaction::Eip1559 {
}) => Self::Eip1559 {
chain_id: *chain_id,
sender,
hash: tx_hash,
@ -1089,7 +1071,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction {
access_list,
blob_versioned_hashes: _,
placeholder,
}) => MockTransaction::Eip4844 {
}) => Self::Eip4844 {
chain_id: *chain_id,
sender,
hash: tx_hash,
@ -1114,7 +1096,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction {
.boxed()
}
type Strategy = proptest::strategy::BoxedStrategy<MockTransaction>;
type Strategy = proptest::strategy::BoxedStrategy<Self>;
}
/// A factory for creating and managing various types of mock transactions.
@ -1433,7 +1415,7 @@ impl NonConflictingSetOutcome {
/// Returns the inner [MockTransactionSet]
pub fn into_inner(self) -> MockTransactionSet {
match self {
NonConflictingSetOutcome::BlobsOnly(set) | NonConflictingSetOutcome::Mixed(set) => set,
Self::BlobsOnly(set) | Self::Mixed(set) => set,
}
}
@ -1451,8 +1433,8 @@ impl NonConflictingSetOutcome {
rng: &mut impl rand::Rng,
) {
match self {
NonConflictingSetOutcome::BlobsOnly(_) => {}
NonConflictingSetOutcome::Mixed(set) => set.with_nonce_gaps(gap_pct, gap_range, rng),
Self::BlobsOnly(_) => {}
Self::Mixed(set) => set.with_nonce_gaps(gap_pct, gap_range, rng),
}
}
}

View File

@ -497,7 +497,7 @@ impl PropagateKind {
/// Returns the peer the transaction was sent to
pub const fn peer(&self) -> &PeerId {
match self {
PropagateKind::Full(peer) | PropagateKind::Hash(peer) => peer,
Self::Full(peer) | Self::Hash(peer) => peer,
}
}
}
@ -561,16 +561,16 @@ pub enum TransactionOrigin {
impl TransactionOrigin {
/// Whether the transaction originates from a local source.
pub const fn is_local(&self) -> bool {
matches!(self, TransactionOrigin::Local)
matches!(self, Self::Local)
}
/// Whether the transaction originates from an external source.
pub const fn is_external(&self) -> bool {
matches!(self, TransactionOrigin::External)
matches!(self, Self::External)
}
/// Whether the transaction originates from a private source.
pub const fn is_private(&self) -> bool {
matches!(self, TransactionOrigin::Private)
matches!(self, Self::Private)
}
}
@ -909,7 +909,7 @@ impl EthBlobTransactionSidecar {
/// Returns the blob sidecar if it is present
pub const fn maybe_sidecar(&self) -> Option<&BlobTransactionSidecar> {
match self {
EthBlobTransactionSidecar::Present(sidecar) => Some(sidecar),
Self::Present(sidecar) => Some(sidecar),
_ => None,
}
}
@ -969,13 +969,13 @@ impl From<PooledTransactionsElementEcRecovered> for EthPooledTransaction {
// include the blob sidecar
let (tx, blob) = tx.into_parts();
let tx = TransactionSignedEcRecovered::from_signed_transaction(tx, signer);
let mut pooled = EthPooledTransaction::new(tx, encoded_length);
let mut pooled = Self::new(tx, encoded_length);
pooled.blob_sidecar = EthBlobTransactionSidecar::Present(blob);
pooled
}
tx => {
// no blob sidecar
EthPooledTransaction::new(tx.into_ecrecovered_transaction(signer), encoded_length)
Self::new(tx.into_ecrecovered_transaction(signer), encoded_length)
}
}
}
@ -1146,14 +1146,14 @@ impl TryFromRecoveredTransaction for EthPooledTransaction {
};
let encoded_length = tx.length_without_header();
let transaction = EthPooledTransaction::new(tx, encoded_length);
let transaction = Self::new(tx, encoded_length);
Ok(transaction)
}
}
impl FromRecoveredPooledTransaction for EthPooledTransaction {
fn from_recovered_pooled_transaction(tx: PooledTransactionsElementEcRecovered) -> Self {
EthPooledTransaction::from(tx)
Self::from(tx)
}
}
@ -1231,8 +1231,8 @@ impl GetPooledTransactionLimit {
#[inline]
pub const fn exceeds(&self, size: usize) -> bool {
match self {
GetPooledTransactionLimit::None => false,
GetPooledTransactionLimit::ResponseSizeSoftLimit(limit) => size > *limit,
Self::None => false,
Self::ResponseSizeSoftLimit(limit) => size > *limit,
}
}
}

View File

@ -42,7 +42,7 @@ impl ValidationTask {
/// Creates a new task with the given receiver.
pub fn with_receiver(jobs: mpsc::Receiver<Pin<Box<dyn Future<Output = ()> + Send>>>) -> Self {
ValidationTask { validation_jobs: Arc::new(Mutex::new(ReceiverStream::new(jobs))) }
Self { validation_jobs: Arc::new(Mutex::new(ReceiverStream::new(jobs))) }
}
/// Executes all new validation jobs that come in.