Skip to content

Commit

Permalink
feat: feature gate tokio::net lookup (#9289)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jul 4, 2024
1 parent 27ed813 commit afe8689
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/net/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ reth-storage-api.workspace = true
reth-provider = { workspace = true, optional = true }
reth-tokio-util.workspace = true
reth-consensus.workspace = true
reth-network-peers.workspace = true
reth-network-peers = { workspace = true, features = ["net"] }
reth-network-types.workspace = true

# ethereum
Expand Down
4 changes: 3 additions & 1 deletion crates/net/peers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ secp256k1 = { workspace = true, optional = true }
serde_with.workspace = true
thiserror.workspace = true
url.workspace = true
tokio = { workspace = true, features = ["full"] }
tokio = { workspace = true, optional = true }

[dev-dependencies]
alloy-primitives = { workspace = true, features = ["rand"] }
rand.workspace = true
secp256k1 = { workspace = true, features = ["rand"] }
serde_json.workspace = true
tokio = { workspace = true, features = ["net", "macros", "rt"] }

[features]
secp256k1 = ["dep:secp256k1", "enr/secp256k1"]
net = ["dep:tokio", "tokio?/net"]
5 changes: 5 additions & 0 deletions crates/net/peers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
//! - [`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
//! static.
//!
//!
//! ## Feature Flags
//!
//! - `net`: Support for address lookups.
#![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
Expand Down
1 change: 1 addition & 0 deletions crates/net/peers/src/trusted_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl TrustedPeer {
}

/// 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> {
let domain = match self.try_node_record() {
Ok(record) => return Ok(record),
Expand Down

0 comments on commit afe8689

Please sign in to comment.