mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 17:18:08 -05:00
feat(txpool) - add flag for local tx propagation (#3977)
This commit is contained in:
@@ -140,6 +140,8 @@ pub struct EthTransactionValidatorBuilder {
|
||||
///
|
||||
/// Default is 1
|
||||
additional_tasks: usize,
|
||||
/// Toggle to determine if a local transaction should be propagated
|
||||
propagate_local_transactions: bool,
|
||||
}
|
||||
|
||||
impl EthTransactionValidatorBuilder {
|
||||
@@ -153,6 +155,8 @@ impl EthTransactionValidatorBuilder {
|
||||
block_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
|
||||
minimum_priority_fee: None,
|
||||
additional_tasks: 1,
|
||||
// default to true, can potentially take this as a param in the future
|
||||
propagate_local_transactions: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +192,23 @@ impl EthTransactionValidatorBuilder {
|
||||
self.eip1559 = eip1559;
|
||||
self
|
||||
}
|
||||
/// Sets toggle to propagate transactions received locally by this client (e.g
|
||||
/// transactions from eth_Sendtransaction to this nodes' RPC server)
|
||||
///
|
||||
/// 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 {
|
||||
self.propagate_local_transactions = propagate_local_txs;
|
||||
self
|
||||
}
|
||||
/// Disables propagating transactions recieved locally by this client
|
||||
///
|
||||
/// For more information, check docs for set_propagate_local_transactions
|
||||
pub fn no_local_transaction_propagation(mut self) -> Self {
|
||||
self.propagate_local_transactions = false;
|
||||
self
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
@@ -222,6 +243,7 @@ impl EthTransactionValidatorBuilder {
|
||||
block_gas_limit,
|
||||
minimum_priority_fee,
|
||||
additional_tasks,
|
||||
propagate_local_transactions,
|
||||
} = self;
|
||||
|
||||
let inner = EthTransactionValidatorInner {
|
||||
@@ -232,6 +254,7 @@ impl EthTransactionValidatorBuilder {
|
||||
eip1559,
|
||||
block_gas_limit,
|
||||
minimum_priority_fee,
|
||||
propagate_local_transactions,
|
||||
_marker: Default::default(),
|
||||
};
|
||||
|
||||
@@ -277,6 +300,8 @@ struct EthTransactionValidatorInner<Client, T> {
|
||||
minimum_priority_fee: Option<u128>,
|
||||
/// Marker for the transaction type
|
||||
_marker: PhantomData<T>,
|
||||
/// Toggle to determine if a local transaction should be propagated
|
||||
propagate_local_transactions: bool,
|
||||
}
|
||||
|
||||
// === impl EthTransactionValidatorInner ===
|
||||
@@ -435,7 +460,9 @@ where
|
||||
balance: account.balance,
|
||||
state_nonce: account.nonce,
|
||||
transaction,
|
||||
propagate: true,
|
||||
// by this point assume all external transactions should be propagated
|
||||
propagate: matches!(origin, TransactionOrigin::External) ||
|
||||
self.propagate_local_transactions,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user