feat: add network request proxy example (#13974)

This commit is contained in:
Matthias Seitz
2025-01-27 19:49:03 +01:00
committed by GitHub
parent 6b1b9c41aa
commit afd43db9b8
7 changed files with 150 additions and 0 deletions

View File

@ -369,6 +369,12 @@ impl<N: NetworkPrimitives> NetworkConfigBuilder<N> {
self
}
/// Launches the network with an unused network and discovery port
/// This is useful for testing.
pub fn with_unused_ports(self) -> Self {
self.with_unused_discovery_port().with_unused_listener_port()
}
/// Sets the discovery port to an unused port.
/// This is useful for testing.
pub fn with_unused_discovery_port(self) -> Self {

View File

@ -168,3 +168,6 @@ pub use metrics::TxTypesCounter;
pub use network::{NetworkHandle, NetworkProtocols};
pub use swarm::NetworkConnectionState;
pub use transactions::{FilterAnnouncement, MessageFilter, ValidateTx68};
/// re-export p2p interfaces
pub use reth_network_p2p as p2p;

View File

@ -159,6 +159,16 @@ impl NetworkManager {
}
impl<N: NetworkPrimitives> NetworkManager<N> {
/// Sets the dedicated channel for events indented for the
/// [`TransactionsManager`](crate::transactions::TransactionsManager).
pub fn with_transactions(
mut self,
tx: mpsc::UnboundedSender<NetworkTransactionEvent<N>>,
) -> Self {
self.set_transactions(tx);
self
}
/// Sets the dedicated channel for events indented for the
/// [`TransactionsManager`](crate::transactions::TransactionsManager).
pub fn set_transactions(&mut self, tx: mpsc::UnboundedSender<NetworkTransactionEvent<N>>) {
@ -166,6 +176,13 @@ impl<N: NetworkPrimitives> NetworkManager<N> {
Some(UnboundedMeteredSender::new(tx, NETWORK_POOL_TRANSACTIONS_SCOPE));
}
/// Sets the dedicated channel for events indented for the
/// [`EthRequestHandler`](crate::eth_requests::EthRequestHandler).
pub fn with_eth_request_handler(mut self, tx: mpsc::Sender<IncomingEthRequest<N>>) -> Self {
self.set_eth_request_handler(tx);
self
}
/// Sets the dedicated channel for events indented for the
/// [`EthRequestHandler`](crate::eth_requests::EthRequestHandler).
pub fn set_eth_request_handler(&mut self, tx: mpsc::Sender<IncomingEthRequest<N>>) {