feat: feature gate tokio::net lookup (#9289)

This commit is contained in:
Matthias Seitz
2024-07-04 12:16:39 +02:00
committed by GitHub
parent 27ed81317f
commit afe86895ff
4 changed files with 10 additions and 2 deletions

View File

@ -30,7 +30,7 @@ reth-storage-api.workspace = true
reth-provider = { workspace = true, optional = true } reth-provider = { workspace = true, optional = true }
reth-tokio-util.workspace = true reth-tokio-util.workspace = true
reth-consensus.workspace = true reth-consensus.workspace = true
reth-network-peers.workspace = true reth-network-peers = { workspace = true, features = ["net"] }
reth-network-types.workspace = true reth-network-types.workspace = true
# ethereum # ethereum

View File

@ -25,13 +25,15 @@ secp256k1 = { workspace = true, optional = true }
serde_with.workspace = true serde_with.workspace = true
thiserror.workspace = true thiserror.workspace = true
url.workspace = true url.workspace = true
tokio = { workspace = true, features = ["full"] } tokio = { workspace = true, optional = true }
[dev-dependencies] [dev-dependencies]
alloy-primitives = { workspace = true, features = ["rand"] } alloy-primitives = { workspace = true, features = ["rand"] }
rand.workspace = true rand.workspace = true
secp256k1 = { workspace = true, features = ["rand"] } secp256k1 = { workspace = true, features = ["rand"] }
serde_json.workspace = true serde_json.workspace = true
tokio = { workspace = true, features = ["net", "macros", "rt"] }
[features] [features]
secp256k1 = ["dep:secp256k1", "enr/secp256k1"] secp256k1 = ["dep:secp256k1", "enr/secp256k1"]
net = ["dep:tokio", "tokio?/net"]

View File

@ -39,6 +39,11 @@
//! - [`TrustedPeer`]: A [`NodeRecord`] with an optional domain name, which can be resolved to a //! - [`TrustedPeer`]: A [`NodeRecord`] with an optional domain name, which can be resolved to a
//! [`NodeRecord`]. Useful for adding trusted peers at startup, whose IP address may not be //! [`NodeRecord`]. Useful for adding trusted peers at startup, whose IP address may not be
//! static. //! static.
//!
//!
//! ## Feature Flags
//!
//! - `net`: Support for address lookups.
#![doc( #![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png", html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",

View File

@ -76,6 +76,7 @@ impl TrustedPeer {
} }
/// Resolves the host in a [`TrustedPeer`] to an IP address, returning a [`NodeRecord`]. /// Resolves the host in a [`TrustedPeer`] to an IP address, returning a [`NodeRecord`].
#[cfg(any(test, feature = "net"))]
pub async fn resolve(&self) -> Result<NodeRecord, Error> { pub async fn resolve(&self) -> Result<NodeRecord, Error> {
let domain = match self.try_node_record() { let domain = match self.try_node_record() {
Ok(record) => return Ok(record), Ok(record) => return Ok(record),