mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: simplify builder fn (#4284)
This commit is contained in:
@ -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 {
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user