diff --git a/crates/net/eth-wire/tests/pooled_transactions.rs b/crates/net/eth-wire/tests/pooled_transactions.rs index 3b17d04cba51..93a17f3b05ba 100644 --- a/crates/net/eth-wire/tests/pooled_transactions.rs +++ b/crates/net/eth-wire/tests/pooled_transactions.rs @@ -3,7 +3,7 @@ use alloy_eips::eip2718::Decodable2718; use alloy_primitives::hex; use alloy_rlp::{Decodable, Encodable}; -use reth_eth_wire::{EthVersion, PooledTransactions, ProtocolMessage}; +use reth_eth_wire::{EthNetworkPrimitives, EthVersion, PooledTransactions, ProtocolMessage}; use reth_primitives::PooledTransactionsElement; use std::{fs, path::PathBuf}; use test_fuzz::test_fuzz; @@ -51,7 +51,7 @@ fn decode_request_pair_pooled_blob_transactions() { .join("testdata/request_pair_pooled_blob_transactions"); let data = fs::read_to_string(network_data_path).expect("Unable to read file"); let hex_data = hex::decode(data.trim()).unwrap(); - let _txs: ProtocolMessage = + let _txs: ProtocolMessage = ProtocolMessage::decode_message(EthVersion::Eth68, &mut &hex_data[..]).unwrap(); } diff --git a/crates/net/network/src/builder.rs b/crates/net/network/src/builder.rs index da003a2e2907..13c932d46442 100644 --- a/crates/net/network/src/builder.rs +++ b/crates/net/network/src/builder.rs @@ -24,35 +24,50 @@ pub struct NetworkBuilder // === impl NetworkBuilder === -impl NetworkBuilder { +impl NetworkBuilder { /// Consumes the type and returns all fields. - pub fn split(self) -> (NetworkManager, Tx, Eth) { + pub fn split(self) -> (NetworkManager, Tx, Eth) { let Self { network, transactions, request_handler } = self; (network, transactions, request_handler) } /// Returns the network manager. - pub const fn network(&self) -> &NetworkManager { + pub const fn network(&self) -> &NetworkManager { &self.network } /// Returns the mutable network manager. - pub fn network_mut(&mut self) -> &mut NetworkManager { + pub fn network_mut(&mut self) -> &mut NetworkManager { &mut self.network } /// Returns the handle to the network. - pub fn handle(&self) -> NetworkHandle { + pub fn handle(&self) -> NetworkHandle { self.network.handle().clone() } /// Consumes the type and returns all fields and also return a [`NetworkHandle`]. - pub fn split_with_handle(self) -> (NetworkHandle, NetworkManager, Tx, Eth) { + pub fn split_with_handle(self) -> (NetworkHandle, NetworkManager, Tx, Eth) { let Self { network, transactions, request_handler } = self; let handle = network.handle().clone(); (handle, network, transactions, request_handler) } + /// Creates a new [`EthRequestHandler`] and wires it to the network. + pub fn request_handler( + self, + client: Client, + ) -> NetworkBuilder, N> { + let Self { mut network, transactions, .. } = self; + let (tx, rx) = mpsc::channel(ETH_REQUEST_CHANNEL_CAPACITY); + network.set_eth_request_handler(tx); + let peers = network.handle().peers_handle().clone(); + let request_handler = EthRequestHandler::new(client, peers, rx); + NetworkBuilder { network, request_handler, transactions } + } +} + +impl NetworkBuilder { /// Creates a new [`TransactionsManager`] and wires it to the network. pub fn transactions( self, @@ -66,17 +81,4 @@ impl NetworkBuilder { let transactions = TransactionsManager::new(handle, pool, rx, transactions_manager_config); NetworkBuilder { network, request_handler, transactions } } - - /// Creates a new [`EthRequestHandler`] and wires it to the network. - pub fn request_handler( - self, - client: Client, - ) -> NetworkBuilder> { - let Self { mut network, transactions, .. } = self; - let (tx, rx) = mpsc::channel(ETH_REQUEST_CHANNEL_CAPACITY); - network.set_eth_request_handler(tx); - let peers = network.handle().peers_handle().clone(); - let request_handler = EthRequestHandler::new(client, peers, rx); - NetworkBuilder { network, request_handler, transactions } - } } diff --git a/crates/net/network/src/config.rs b/crates/net/network/src/config.rs index 44f34c3a4b08..a9ce67821b98 100644 --- a/crates/net/network/src/config.rs +++ b/crates/net/network/src/config.rs @@ -94,7 +94,7 @@ impl NetworkConfig<(), N> { } /// Convenience method for creating the corresponding builder type with a random secret key. - pub fn builder_with_rng_secret_key() -> NetworkConfigBuilder { + pub fn builder_with_rng_secret_key() -> NetworkConfigBuilder { NetworkConfigBuilder::with_rng_secret_key() } }