chore: simplify builder fn (#4284)

This commit is contained in:
Matthias Seitz
2023-08-20 13:07:32 +02:00
committed by GitHub
parent 6512603348
commit 9ebeca3bef
6 changed files with 14 additions and 14 deletions

View File

@ -76,16 +76,18 @@ pub struct NetworkConfig<C> {
// === impl NetworkConfig ===
impl<C> NetworkConfig<C> {
/// Create a new instance with all mandatory fields set, rest is field with defaults.
pub fn new(client: C, secret_key: SecretKey) -> Self {
Self::builder(secret_key).build(client)
}
impl NetworkConfig<()> {
/// Convenience method for creating the corresponding builder type
pub fn builder(secret_key: SecretKey) -> NetworkConfigBuilder {
NetworkConfigBuilder::new(secret_key)
}
}
impl<C> NetworkConfig<C> {
/// Create a new instance with all mandatory fields set, rest is field with defaults.
pub fn new(client: C, secret_key: SecretKey) -> Self {
NetworkConfig::builder(secret_key).build(client)
}
/// Sets the config to use for the discovery v4 protocol.
pub fn set_discovery_v4(mut self, discovery_config: Discv4Config) -> Self {

View File

@ -71,7 +71,7 @@
//! // The key that's used for encrypting sessions and to identify our node.
//! let local_key = rng_secret_key();
//!
//! let config = NetworkConfig::<NoopProvider>::builder(local_key).boot_nodes(
//! let config = NetworkConfig::builder(local_key).boot_nodes(
//! mainnet_nodes()
//! ).build(client);
//!
@ -101,7 +101,7 @@
//! let local_key = rng_secret_key();
//!
//! let config =
//! NetworkConfig::<NoopProvider>::builder(local_key).boot_nodes(mainnet_nodes()).build(client.clone());
//! NetworkConfig::builder(local_key).boot_nodes(mainnet_nodes()).build(client.clone());
//!
//! // create the network instance
//! let (handle, network, transactions, request_handler) = NetworkManager::builder(config)

View File

@ -271,7 +271,7 @@ where
/// let local_key = rng_secret_key();
///
/// let config =
/// NetworkConfig::<NoopProvider>::builder(local_key).boot_nodes(mainnet_nodes()).build(client.clone());
/// NetworkConfig::builder(local_key).boot_nodes(mainnet_nodes()).build(client.clone());
///
/// // create the network instance
/// let (handle, network, transactions, request_handler) = NetworkManager::builder(config)

View File

@ -32,7 +32,7 @@ async fn can_peer_with_geth() {
"setting up reth networking stack in keepalive test"
);
let config = NetworkConfig::<Arc<NoopProvider>>::builder(secret_key)
let config = NetworkConfig::builder(secret_key)
.listener_addr(reth_p2p)
.discovery_addr(reth_disc)
.chain_spec(chainspec)