fix: put noop helper behind feature (#6433)

This commit is contained in:
Matthias Seitz
2024-02-06 03:32:18 +01:00
committed by GitHub
parent 25d2a67577
commit e810687ba7
2 changed files with 10 additions and 4 deletions

View File

@ -14,7 +14,7 @@ use reth_eth_wire::{HelloMessage, HelloMessageWithProtocols, Status};
use reth_primitives::{
mainnet_nodes, sepolia_nodes, ChainSpec, ForkFilter, Head, NodeRecord, PeerId, MAINNET,
};
use reth_provider::{test_utils::NoopProvider, BlockReader, HeaderProvider};
use reth_provider::{BlockReader, HeaderProvider};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use secp256k1::SECP256K1;
use std::{collections::HashSet, net::SocketAddr, sync::Arc};
@ -412,8 +412,12 @@ impl NetworkConfigBuilder {
self
}
pub fn build_with_noop_provider(self) -> NetworkConfig<NoopProvider> {
self.build(NoopProvider::default())
/// Convenience function for creating a [NetworkConfig] with a noop provider that does nothing.
#[cfg(any(test, feature = "test-utils"))]
pub fn build_with_noop_provider(
self,
) -> NetworkConfig<reth_provider::test_utils::NoopProvider> {
self.build(reth_provider::test_utils::NoopProvider::default())
}
/// Consumes the type and creates the actual [`NetworkConfig`]

View File

@ -14,6 +14,7 @@ use reth_discv4::Discv4ConfigBuilder;
use reth_network::{
config::NetworkMode, NetworkConfig, NetworkEvent, NetworkEvents, NetworkManager,
};
use reth_provider::test_utils::NoopProvider;
use reth_tracing::{
tracing::info, tracing_subscriber::filter::LevelFilter, LayerInfo, LogFormat, RethTracer,
Tracer,
@ -24,6 +25,7 @@ use std::{
time::Duration,
};
use tokio_stream::StreamExt;
pub mod chain_cfg;
#[tokio::main]
@ -49,7 +51,7 @@ async fn main() {
.set_head(head())
.network_mode(NetworkMode::Work)
.listener_addr(local_addr)
.build_with_noop_provider();
.build(NoopProvider::default());
// Set Discv4 lookup interval to 1 second
let mut discv4_cfg = Discv4ConfigBuilder::default();