mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: apply missing const for fn lint txpool (#6381)
This commit is contained in:
@ -96,7 +96,7 @@ pub struct PriceBumpConfig {
|
||||
impl PriceBumpConfig {
|
||||
/// Returns the price bump required to replace the given transaction type.
|
||||
#[inline]
|
||||
pub(crate) fn price_bump(&self, tx_type: u8) -> u128 {
|
||||
pub(crate) const fn price_bump(&self, tx_type: u8) -> u128 {
|
||||
if tx_type == EIP4844_TX_TYPE_ID {
|
||||
return self.replace_blob_tx_price_bump
|
||||
}
|
||||
@ -143,7 +143,7 @@ impl Default for LocalTransactionConfig {
|
||||
impl LocalTransactionConfig {
|
||||
/// Returns whether local transactions are not exempt from the configured limits.
|
||||
#[inline]
|
||||
pub fn no_local_exemptions(&self) -> bool {
|
||||
pub const fn no_local_exemptions(&self) -> bool {
|
||||
self.no_exemptions
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ impl LocalTransactionConfig {
|
||||
/// If set to false, only transactions received by network peers (via
|
||||
/// p2p) will be marked as propagated in the local transaction pool and returned on a
|
||||
/// GetPooledTransactions p2p request
|
||||
pub fn set_propagate_local_transactions(mut self, propagate_local_txs: bool) -> Self {
|
||||
pub const fn set_propagate_local_transactions(mut self, propagate_local_txs: bool) -> Self {
|
||||
self.propagate_local_transactions = propagate_local_txs;
|
||||
self
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ pub struct SenderId(u64);
|
||||
|
||||
impl SenderId {
|
||||
/// Returns a `Bound` for `TransactionId` starting with nonce `0`
|
||||
pub(crate) fn start_bound(self) -> std::ops::Bound<TransactionId> {
|
||||
pub(crate) const fn start_bound(self) -> std::ops::Bound<TransactionId> {
|
||||
std::ops::Bound::Included(TransactionId::new(self, 0))
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,7 @@ pub struct TransactionId {
|
||||
|
||||
impl TransactionId {
|
||||
/// Create a new identifier pair
|
||||
pub fn new(sender: SenderId, nonce: u64) -> Self {
|
||||
pub const fn new(sender: SenderId, nonce: u64) -> Self {
|
||||
Self { sender, nonce }
|
||||
}
|
||||
|
||||
@ -110,13 +110,13 @@ impl TransactionId {
|
||||
}
|
||||
|
||||
/// Returns the `TransactionId` that directly follows this transaction: `self.nonce + 1`
|
||||
pub fn descendant(&self) -> TransactionId {
|
||||
pub const fn descendant(&self) -> TransactionId {
|
||||
TransactionId::new(self.sender, self.nonce + 1)
|
||||
}
|
||||
|
||||
/// Returns the nonce the follows directly after this.
|
||||
#[inline]
|
||||
pub(crate) fn next_nonce(&self) -> u64 {
|
||||
pub(crate) const fn next_nonce(&self) -> u64 {
|
||||
self.nonce + 1
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,6 +147,7 @@
|
||||
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
|
||||
)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
#![warn(clippy::missing_const_for_fn)]
|
||||
|
||||
use crate::{identifier::TransactionId, pool::PoolInner};
|
||||
use aquamarine as _;
|
||||
|
||||
@ -59,7 +59,7 @@ pub struct LocalTransactionBackupConfig {
|
||||
|
||||
impl LocalTransactionBackupConfig {
|
||||
/// Receive path to transactions backup and return initialized config
|
||||
pub fn with_local_txs_backup(transactions_path: PathBuf) -> Self {
|
||||
pub const fn with_local_txs_backup(transactions_path: PathBuf) -> Self {
|
||||
Self { transactions_path: Some(transactions_path) }
|
||||
}
|
||||
}
|
||||
@ -436,7 +436,7 @@ struct FinalizedBlockTracker {
|
||||
}
|
||||
|
||||
impl FinalizedBlockTracker {
|
||||
fn new(last_finalized_block: Option<BlockNumber>) -> Self {
|
||||
const fn new(last_finalized_block: Option<BlockNumber>) -> Self {
|
||||
Self { last_finalized_block }
|
||||
}
|
||||
|
||||
@ -473,7 +473,7 @@ enum MaintainedPoolState {
|
||||
impl MaintainedPoolState {
|
||||
/// Returns `true` if the pool is assumed to be out of sync with the current state.
|
||||
#[inline]
|
||||
fn is_drifted(&self) -> bool {
|
||||
const fn is_drifted(&self) -> bool {
|
||||
matches!(self, MaintainedPoolState::Drifted)
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ pub struct NoopInsertError {
|
||||
}
|
||||
|
||||
impl NoopInsertError {
|
||||
fn new(tx: EthPooledTransaction) -> Self {
|
||||
const fn new(tx: EthPooledTransaction) -> Self {
|
||||
Self { tx }
|
||||
}
|
||||
|
||||
|
||||
@ -204,7 +204,7 @@ pub struct BestTransactionFilter<I, P> {
|
||||
|
||||
impl<I, P> BestTransactionFilter<I, P> {
|
||||
/// Create a new [`BestTransactionFilter`] with the given predicate.
|
||||
pub(crate) fn new(best: I, predicate: P) -> Self {
|
||||
pub(crate) const fn new(best: I, predicate: P) -> Self {
|
||||
Self { best, predicate }
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ impl<T: PoolTransaction> BlobTransactions<T> {
|
||||
}
|
||||
|
||||
/// Returns all transactions that satisfy the given basefee and blob_fee.
|
||||
pub(crate) fn satisfy_attributes(
|
||||
pub(crate) const fn satisfy_attributes(
|
||||
&self,
|
||||
_best_transactions_attributes: BestTransactionsAttributes,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T>>> {
|
||||
|
||||
@ -79,7 +79,7 @@ pub enum TransactionEvent {
|
||||
impl TransactionEvent {
|
||||
/// Returns `true` if the event is final and no more events are expected for this transaction
|
||||
/// hash.
|
||||
pub fn is_final(&self) -> bool {
|
||||
pub const fn is_final(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
TransactionEvent::Replaced(_) |
|
||||
|
||||
@ -30,7 +30,7 @@ pub struct TransactionEvents {
|
||||
|
||||
impl TransactionEvents {
|
||||
/// The hash for this transaction
|
||||
pub fn hash(&self) -> TxHash {
|
||||
pub const fn hash(&self) -> TxHash {
|
||||
self.hash
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ where
|
||||
}
|
||||
|
||||
/// Returns the configured blob store.
|
||||
pub(crate) fn blob_store(&self) -> &S {
|
||||
pub(crate) const fn blob_store(&self) -> &S {
|
||||
&self.blob_store
|
||||
}
|
||||
|
||||
@ -222,12 +222,12 @@ where
|
||||
}
|
||||
|
||||
/// Get the config the pool was configured with.
|
||||
pub fn config(&self) -> &PoolConfig {
|
||||
pub const fn config(&self) -> &PoolConfig {
|
||||
&self.config
|
||||
}
|
||||
|
||||
/// Get the validator reference.
|
||||
pub fn validator(&self) -> &V {
|
||||
pub const fn validator(&self) -> &V {
|
||||
&self.validator
|
||||
}
|
||||
|
||||
@ -999,7 +999,7 @@ pub enum AddedTransaction<T: PoolTransaction> {
|
||||
|
||||
impl<T: PoolTransaction> AddedTransaction<T> {
|
||||
/// Returns whether the transaction has been added to the pending pool.
|
||||
pub(crate) fn as_pending(&self) -> Option<&AddedPendingTransaction<T>> {
|
||||
pub(crate) const fn as_pending(&self) -> Option<&AddedPendingTransaction<T>> {
|
||||
match self {
|
||||
AddedTransaction::Pending(tx) => Some(tx),
|
||||
_ => None,
|
||||
@ -1007,7 +1007,7 @@ impl<T: PoolTransaction> AddedTransaction<T> {
|
||||
}
|
||||
|
||||
/// Returns the replaced transaction if there was one
|
||||
pub(crate) fn replaced(&self) -> Option<&Arc<ValidPoolTransaction<T>>> {
|
||||
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(),
|
||||
@ -1049,7 +1049,7 @@ impl<T: PoolTransaction> AddedTransaction<T> {
|
||||
|
||||
/// Returns the subpool this transaction was added to
|
||||
#[cfg(test)]
|
||||
pub(crate) fn subpool(&self) -> SubPool {
|
||||
pub(crate) const fn subpool(&self) -> SubPool {
|
||||
match self {
|
||||
AddedTransaction::Pending(_) => SubPool::Pending,
|
||||
AddedTransaction::Parked { subpool, .. } => *subpool,
|
||||
|
||||
@ -325,7 +325,7 @@ impl<T: ParkedOrd> Ord for ParkedPoolTransaction<T> {
|
||||
|
||||
/// Includes a [SenderId] and `submission_id`. This is used to sort senders by their last
|
||||
/// submission id.
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||
pub struct SubmissionSenderId {
|
||||
/// The sender id
|
||||
pub(crate) sender_id: SenderId,
|
||||
@ -335,7 +335,7 @@ pub struct SubmissionSenderId {
|
||||
|
||||
impl SubmissionSenderId {
|
||||
/// Creates a new [SubmissionSenderId] based on the [SenderId] and `submission_id`.
|
||||
fn new(sender_id: SenderId, submission_id: u64) -> Self {
|
||||
const fn new(sender_id: SenderId, submission_id: u64) -> Self {
|
||||
Self { sender_id, submission_id }
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,19 +48,19 @@ impl TxState {
|
||||
/// - enough fee cap
|
||||
/// - enough blob fee cap
|
||||
#[inline]
|
||||
pub(crate) fn is_pending(&self) -> bool {
|
||||
pub(crate) const fn is_pending(&self) -> bool {
|
||||
self.bits() >= TxState::PENDING_POOL_BITS.bits()
|
||||
}
|
||||
|
||||
/// Whether this transaction is a blob transaction.
|
||||
#[inline]
|
||||
pub(crate) fn is_blob(&self) -> bool {
|
||||
pub(crate) const fn is_blob(&self) -> bool {
|
||||
self.contains(TxState::BLOB_TRANSACTION)
|
||||
}
|
||||
|
||||
/// Returns `true` if the transaction has a nonce gap.
|
||||
#[inline]
|
||||
pub(crate) fn has_nonce_gap(&self) -> bool {
|
||||
pub(crate) const fn has_nonce_gap(&self) -> bool {
|
||||
!self.intersects(TxState::NO_NONCE_GAPS)
|
||||
}
|
||||
}
|
||||
@ -86,25 +86,25 @@ pub enum SubPool {
|
||||
impl SubPool {
|
||||
/// Whether this transaction is to be moved to the pending sub-pool.
|
||||
#[inline]
|
||||
pub fn is_pending(&self) -> bool {
|
||||
pub const fn is_pending(&self) -> bool {
|
||||
matches!(self, SubPool::Pending)
|
||||
}
|
||||
|
||||
/// Whether this transaction is in the queued pool.
|
||||
#[inline]
|
||||
pub fn is_queued(&self) -> bool {
|
||||
pub const fn is_queued(&self) -> bool {
|
||||
matches!(self, SubPool::Queued)
|
||||
}
|
||||
|
||||
/// Whether this transaction is in the base fee pool.
|
||||
#[inline]
|
||||
pub fn is_base_fee(&self) -> bool {
|
||||
pub const fn is_base_fee(&self) -> bool {
|
||||
matches!(self, SubPool::BaseFee)
|
||||
}
|
||||
|
||||
/// Whether this transaction is in the blob pool.
|
||||
#[inline]
|
||||
pub fn is_blob(&self) -> bool {
|
||||
pub const fn is_blob(&self) -> bool {
|
||||
matches!(self, SubPool::Blob)
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ impl<T: TransactionOrdering> TxPool<T> {
|
||||
}
|
||||
|
||||
/// Returns access to the [`AllTransactions`] container.
|
||||
pub(crate) fn all(&self) -> &AllTransactions<T::Transaction> {
|
||||
pub(crate) const fn all(&self) -> &AllTransactions<T::Transaction> {
|
||||
&self.all_transactions
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ impl<T: TransactionOrdering> TxPool<T> {
|
||||
}
|
||||
|
||||
/// Returns the currently tracked block values
|
||||
pub(crate) fn block_info(&self) -> BlockInfo {
|
||||
pub(crate) const fn block_info(&self) -> BlockInfo {
|
||||
BlockInfo {
|
||||
last_seen_block_hash: self.all_transactions.last_seen_block_hash,
|
||||
last_seen_block_number: self.all_transactions.last_seen_block_number,
|
||||
@ -887,15 +887,15 @@ impl<T: TransactionOrdering> Drop for TxPool<T> {
|
||||
#[cfg(any(test, feature = "test-utils"))]
|
||||
#[allow(dead_code)]
|
||||
impl<T: TransactionOrdering> TxPool<T> {
|
||||
pub(crate) fn pending(&self) -> &PendingPool<T> {
|
||||
pub(crate) const fn pending(&self) -> &PendingPool<T> {
|
||||
&self.pending_pool
|
||||
}
|
||||
|
||||
pub(crate) fn base_fee(&self) -> &ParkedPool<BasefeeOrd<T::Transaction>> {
|
||||
pub(crate) const fn base_fee(&self) -> &ParkedPool<BasefeeOrd<T::Transaction>> {
|
||||
&self.basefee_pool
|
||||
}
|
||||
|
||||
pub(crate) fn queued(&self) -> &ParkedPool<QueuedOrd<T::Transaction>> {
|
||||
pub(crate) const fn queued(&self) -> &ParkedPool<QueuedOrd<T::Transaction>> {
|
||||
&self.queued_pool
|
||||
}
|
||||
}
|
||||
@ -2018,7 +2018,7 @@ mod tests {
|
||||
|
||||
impl PromotionTest {
|
||||
/// Returns the test case for the opposite update
|
||||
fn opposite(&self) -> Self {
|
||||
const fn opposite(&self) -> Self {
|
||||
Self {
|
||||
basefee: self.basefee_update,
|
||||
blobfee: self.blobfee_update,
|
||||
|
||||
@ -48,7 +48,7 @@ impl<R: Rng> TransactionGenerator<R> {
|
||||
}
|
||||
|
||||
/// Sets the default gas limit for all generated transactions
|
||||
pub fn with_gas_limit(mut self, gas_limit: u64) -> Self {
|
||||
pub const fn with_gas_limit(mut self, gas_limit: u64) -> Self {
|
||||
self.gas_limit = gas_limit;
|
||||
self
|
||||
}
|
||||
@ -60,7 +60,7 @@ impl<R: Rng> TransactionGenerator<R> {
|
||||
}
|
||||
|
||||
/// Sets the base fee for the generated transactions
|
||||
pub fn with_base_fee(mut self, base_fee: u64) -> Self {
|
||||
pub const fn with_base_fee(mut self, base_fee: u64) -> Self {
|
||||
self.base_fee = base_fee as u128;
|
||||
self
|
||||
}
|
||||
@ -170,19 +170,19 @@ impl TransactionBuilder {
|
||||
}
|
||||
|
||||
/// Sets the signer for the transaction builder.
|
||||
pub fn signer(mut self, signer: B256) -> Self {
|
||||
pub const fn signer(mut self, signer: B256) -> Self {
|
||||
self.signer = signer;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the gas limit for the transaction builder.
|
||||
pub fn gas_limit(mut self, gas_limit: u64) -> Self {
|
||||
pub const fn gas_limit(mut self, gas_limit: u64) -> Self {
|
||||
self.gas_limit = gas_limit;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the nonce for the transaction builder.
|
||||
pub fn nonce(mut self, nonce: u64) -> Self {
|
||||
pub const fn nonce(mut self, nonce: u64) -> Self {
|
||||
self.nonce = nonce;
|
||||
self
|
||||
}
|
||||
@ -200,19 +200,19 @@ impl TransactionBuilder {
|
||||
}
|
||||
|
||||
/// Sets the maximum fee per gas for the transaction builder.
|
||||
pub fn max_fee_per_gas(mut self, max_fee_per_gas: u128) -> Self {
|
||||
pub const fn max_fee_per_gas(mut self, max_fee_per_gas: u128) -> Self {
|
||||
self.max_fee_per_gas = max_fee_per_gas;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum priority fee per gas for the transaction builder.
|
||||
pub fn max_priority_fee_per_gas(mut self, max_priority_fee_per_gas: u128) -> Self {
|
||||
pub const fn max_priority_fee_per_gas(mut self, max_priority_fee_per_gas: u128) -> Self {
|
||||
self.max_priority_fee_per_gas = max_priority_fee_per_gas;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the recipient or contract address for the transaction builder.
|
||||
pub fn to(mut self, to: Address) -> Self {
|
||||
pub const fn to(mut self, to: Address) -> Self {
|
||||
self.to = TransactionKind::Call(to);
|
||||
self
|
||||
}
|
||||
@ -236,7 +236,7 @@ impl TransactionBuilder {
|
||||
}
|
||||
|
||||
/// Sets the chain ID for the transaction.
|
||||
pub fn chain_id(mut self, chain_id: u64) -> Self {
|
||||
pub const fn chain_id(mut self, chain_id: u64) -> Self {
|
||||
self.chain_id = chain_id;
|
||||
self
|
||||
}
|
||||
|
||||
@ -397,7 +397,7 @@ impl MockTransaction {
|
||||
}
|
||||
|
||||
/// Gets the priority fee for dynamic fee transactions (EIP-1559 and EIP-4844)
|
||||
pub fn get_priority_fee(&self) -> Option<u128> {
|
||||
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, .. } => {
|
||||
@ -424,7 +424,7 @@ impl MockTransaction {
|
||||
}
|
||||
|
||||
/// Gets the max fee for dynamic fee transactions (EIP-1559 and EIP-4844)
|
||||
pub fn get_max_fee(&self) -> Option<u128> {
|
||||
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),
|
||||
@ -492,7 +492,7 @@ impl MockTransaction {
|
||||
}
|
||||
|
||||
/// Gets the gas price for the transaction.
|
||||
pub fn get_gas_price(&self) -> u128 {
|
||||
pub const fn get_gas_price(&self) -> u128 {
|
||||
match self {
|
||||
MockTransaction::Legacy { gas_price, .. } |
|
||||
MockTransaction::Eip2930 { gas_price, .. } => *gas_price,
|
||||
@ -596,7 +596,7 @@ impl MockTransaction {
|
||||
}
|
||||
|
||||
/// Returns the transaction type identifier associated with the current [MockTransaction].
|
||||
pub fn tx_type(&self) -> u8 {
|
||||
pub const fn tx_type(&self) -> u8 {
|
||||
match self {
|
||||
Self::Legacy { .. } => LEGACY_TX_TYPE_ID,
|
||||
Self::Eip1559 { .. } => EIP1559_TX_TYPE_ID,
|
||||
@ -608,22 +608,22 @@ impl MockTransaction {
|
||||
}
|
||||
|
||||
/// Checks if the transaction is of the legacy type.
|
||||
pub fn is_legacy(&self) -> bool {
|
||||
pub const fn is_legacy(&self) -> bool {
|
||||
matches!(self, MockTransaction::Legacy { .. })
|
||||
}
|
||||
|
||||
/// Checks if the transaction is of the EIP-1559 type.
|
||||
pub fn is_eip1559(&self) -> bool {
|
||||
pub const fn is_eip1559(&self) -> bool {
|
||||
matches!(self, MockTransaction::Eip1559 { .. })
|
||||
}
|
||||
|
||||
/// Checks if the transaction is of the EIP-4844 type.
|
||||
pub fn is_eip4844(&self) -> bool {
|
||||
pub const fn is_eip4844(&self) -> bool {
|
||||
matches!(self, MockTransaction::Eip4844 { .. })
|
||||
}
|
||||
|
||||
/// Checks if the transaction is of the EIP-2930 type.
|
||||
pub fn is_eip2930(&self) -> bool {
|
||||
pub const fn is_eip2930(&self) -> bool {
|
||||
matches!(self, MockTransaction::Eip2930 { .. })
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,7 +401,7 @@ pub enum TransactionListenerKind {
|
||||
impl TransactionListenerKind {
|
||||
/// Returns true if we're only interested in transactions that are allowed to be propagated.
|
||||
#[inline]
|
||||
pub fn is_propagate_only(&self) -> bool {
|
||||
pub const fn is_propagate_only(&self) -> bool {
|
||||
matches!(self, Self::PropagateOnly)
|
||||
}
|
||||
}
|
||||
@ -457,7 +457,7 @@ pub enum PropagateKind {
|
||||
|
||||
impl PropagateKind {
|
||||
/// Returns the peer the transaction was sent to
|
||||
pub fn peer(&self) -> &PeerId {
|
||||
pub const fn peer(&self) -> &PeerId {
|
||||
match self {
|
||||
PropagateKind::Full(peer) => peer,
|
||||
PropagateKind::Hash(peer) => peer,
|
||||
@ -613,7 +613,7 @@ pub struct ChangedAccount {
|
||||
|
||||
impl ChangedAccount {
|
||||
/// Creates a new `ChangedAccount` with the given address and 0 balance and nonce.
|
||||
pub(crate) fn empty(address: Address) -> Self {
|
||||
pub(crate) const fn empty(address: Address) -> Self {
|
||||
Self { address, nonce: 0, balance: U256::ZERO }
|
||||
}
|
||||
}
|
||||
@ -695,17 +695,17 @@ pub struct BestTransactionsAttributes {
|
||||
|
||||
impl BestTransactionsAttributes {
|
||||
/// Creates a new `BestTransactionsAttributes` with the given basefee and blob fee.
|
||||
pub fn new(basefee: u64, blob_fee: Option<u64>) -> Self {
|
||||
pub const fn new(basefee: u64, blob_fee: Option<u64>) -> Self {
|
||||
Self { basefee, blob_fee }
|
||||
}
|
||||
|
||||
/// Creates a new `BestTransactionsAttributes` with the given basefee.
|
||||
pub fn base_fee(basefee: u64) -> Self {
|
||||
pub const fn base_fee(basefee: u64) -> Self {
|
||||
Self::new(basefee, None)
|
||||
}
|
||||
|
||||
/// Sets the given blob fee.
|
||||
pub fn with_blob_fee(mut self, blob_fee: u64) -> Self {
|
||||
pub const fn with_blob_fee(mut self, blob_fee: u64) -> Self {
|
||||
self.blob_fee = Some(blob_fee);
|
||||
self
|
||||
}
|
||||
@ -899,7 +899,7 @@ impl EthPooledTransaction {
|
||||
}
|
||||
|
||||
/// Return the reference to the underlying transaction.
|
||||
pub fn transaction(&self) -> &TransactionSignedEcRecovered {
|
||||
pub const fn transaction(&self) -> &TransactionSignedEcRecovered {
|
||||
&self.transaction
|
||||
}
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ impl IntoRecoveredTransaction for EthPooledTransaction {
|
||||
}
|
||||
|
||||
/// Represents the current status of the pool.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct PoolSize {
|
||||
/// Number of transactions in the _pending_ sub-pool.
|
||||
pub pending: usize,
|
||||
@ -1157,7 +1157,7 @@ pub enum GetPooledTransactionLimit {
|
||||
impl GetPooledTransactionLimit {
|
||||
/// Returns true if the given size exceeds the limit.
|
||||
#[inline]
|
||||
pub fn exceeds(&self, size: usize) -> bool {
|
||||
pub const fn exceeds(&self, size: usize) -> bool {
|
||||
match self {
|
||||
GetPooledTransactionLimit::None => false,
|
||||
GetPooledTransactionLimit::ResponseSizeSoftLimit(limit) => size > *limit,
|
||||
@ -1177,7 +1177,7 @@ pub struct NewSubpoolTransactionStream<Tx: PoolTransaction> {
|
||||
|
||||
impl<Tx: PoolTransaction> NewSubpoolTransactionStream<Tx> {
|
||||
/// Create a new stream that yields full transactions from the subpool
|
||||
pub fn new(st: Receiver<NewTransactionEvent<Tx>>, subpool: SubPool) -> Self {
|
||||
pub const fn new(st: Receiver<NewTransactionEvent<Tx>>, subpool: SubPool) -> Self {
|
||||
Self { st, subpool }
|
||||
}
|
||||
|
||||
|
||||
@ -519,7 +519,7 @@ impl EthTransactionValidatorBuilder {
|
||||
}
|
||||
|
||||
/// Disables the Cancun fork.
|
||||
pub fn no_cancun(self) -> Self {
|
||||
pub const fn no_cancun(self) -> Self {
|
||||
self.set_cancun(false)
|
||||
}
|
||||
|
||||
@ -533,40 +533,40 @@ impl EthTransactionValidatorBuilder {
|
||||
}
|
||||
|
||||
/// Set the Cancun fork.
|
||||
pub fn set_cancun(mut self, cancun: bool) -> Self {
|
||||
pub const fn set_cancun(mut self, cancun: bool) -> Self {
|
||||
self.cancun = cancun;
|
||||
self
|
||||
}
|
||||
|
||||
/// Disables the Shanghai fork.
|
||||
pub fn no_shanghai(self) -> Self {
|
||||
pub const fn no_shanghai(self) -> Self {
|
||||
self.set_shanghai(false)
|
||||
}
|
||||
|
||||
/// Set the Shanghai fork.
|
||||
pub fn set_shanghai(mut self, shanghai: bool) -> Self {
|
||||
pub const fn set_shanghai(mut self, shanghai: bool) -> Self {
|
||||
self.shanghai = shanghai;
|
||||
self
|
||||
}
|
||||
|
||||
/// Disables the eip2718 support.
|
||||
pub fn no_eip2718(self) -> Self {
|
||||
pub const fn no_eip2718(self) -> Self {
|
||||
self.set_eip2718(false)
|
||||
}
|
||||
|
||||
/// Set eip2718 support.
|
||||
pub fn set_eip2718(mut self, eip2718: bool) -> Self {
|
||||
pub const fn set_eip2718(mut self, eip2718: bool) -> Self {
|
||||
self.eip2718 = eip2718;
|
||||
self
|
||||
}
|
||||
|
||||
/// Disables the eip1559 support.
|
||||
pub fn no_eip1559(self) -> Self {
|
||||
pub const fn no_eip1559(self) -> Self {
|
||||
self.set_eip1559(false)
|
||||
}
|
||||
|
||||
/// Set the eip1559 support.
|
||||
pub fn set_eip1559(mut self, eip1559: bool) -> Self {
|
||||
pub const fn set_eip1559(mut self, eip1559: bool) -> Self {
|
||||
self.eip1559 = eip1559;
|
||||
self
|
||||
}
|
||||
@ -578,13 +578,13 @@ impl EthTransactionValidatorBuilder {
|
||||
}
|
||||
|
||||
/// Sets a minimum priority fee that's enforced for acceptance into the pool.
|
||||
pub fn with_minimum_priority_fee(mut self, minimum_priority_fee: u128) -> Self {
|
||||
pub const fn with_minimum_priority_fee(mut self, minimum_priority_fee: u128) -> Self {
|
||||
self.minimum_priority_fee = Some(minimum_priority_fee);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the number of additional tasks to spawn.
|
||||
pub fn with_additional_tasks(mut self, additional_tasks: usize) -> Self {
|
||||
pub const fn with_additional_tasks(mut self, additional_tasks: usize) -> Self {
|
||||
self.additional_tasks = additional_tasks;
|
||||
self
|
||||
}
|
||||
|
||||
@ -63,17 +63,17 @@ impl<T: PoolTransaction> TransactionValidationOutcome<T> {
|
||||
}
|
||||
|
||||
/// Returns true if the transaction is valid.
|
||||
pub fn is_valid(&self) -> bool {
|
||||
pub const fn is_valid(&self) -> bool {
|
||||
matches!(self, Self::Valid { .. })
|
||||
}
|
||||
|
||||
/// Returns true if the transaction is invalid.
|
||||
pub fn is_invalid(&self) -> bool {
|
||||
pub const fn is_invalid(&self) -> bool {
|
||||
matches!(self, Self::Invalid(_, _))
|
||||
}
|
||||
|
||||
/// Returns true if validation resulted in an error.
|
||||
pub fn is_error(&self) -> bool {
|
||||
pub const fn is_error(&self) -> bool {
|
||||
matches!(self, Self::Error(_, _))
|
||||
}
|
||||
}
|
||||
@ -116,7 +116,7 @@ impl<T> ValidTransaction<T> {
|
||||
|
||||
impl<T: PoolTransaction> ValidTransaction<T> {
|
||||
#[inline]
|
||||
pub(crate) fn transaction(&self) -> &T {
|
||||
pub(crate) const fn transaction(&self) -> &T {
|
||||
match self {
|
||||
Self::Valid(transaction) => transaction,
|
||||
Self::ValidWithSidecar { transaction, .. } => transaction,
|
||||
@ -249,12 +249,12 @@ impl<T: PoolTransaction> ValidPoolTransaction<T> {
|
||||
}
|
||||
|
||||
/// Returns the internal identifier for the sender of this transaction
|
||||
pub(crate) fn sender_id(&self) -> SenderId {
|
||||
pub(crate) const fn sender_id(&self) -> SenderId {
|
||||
self.transaction_id.sender
|
||||
}
|
||||
|
||||
/// Returns the internal identifier for this transaction.
|
||||
pub(crate) fn id(&self) -> &TransactionId {
|
||||
pub(crate) const fn id(&self) -> &TransactionId {
|
||||
&self.transaction_id
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ impl<T: PoolTransaction> ValidPoolTransaction<T> {
|
||||
}
|
||||
|
||||
/// Whether the transaction originated locally.
|
||||
pub fn is_local(&self) -> bool {
|
||||
pub const fn is_local(&self) -> bool {
|
||||
self.origin.is_local()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user