Skip to content

Commit 567da5b

Browse files
authored
chore: slim deps (sigp#255)
* chore: use `libp2p-identity` and `multiaddr` Slim down the dependency tree by using `libp2p-identity` and `multiaddr` directly instead of `libp2p` when the `libp2p` feature is enabled * chore: re-export `multiaddr` and `libp2p-identity`
1 parent 44051ef commit 567da5b

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ categories = ["network-programming", "asynchronous"]
1212
exclude = [".gitignore", ".github/*"]
1313

1414
[dependencies]
15-
enr = { version = "0.12", features = ["k256", "ed25519"] }
15+
enr = { version = "0.12", features = ["k256", "ed25519"] }
1616
tokio = { version = "1", features = ["net", "sync", "macros", "rt"] }
17-
libp2p = { version = "0.53", features = ["ed25519", "secp256k1"], optional = true }
17+
libp2p-identity = { version = "0.2", features = [
18+
"ed25519",
19+
"secp256k1",
20+
], optional = true }
21+
multiaddr = { version = "0.18", optional = true }
1822
zeroize = { version = "1", features = ["zeroize_derive"] }
1923
futures = "0.3"
2024
uint = { version = "0.9", default-features = false }
@@ -48,5 +52,5 @@ tokio = { version = "1", features = ["full"] }
4852
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
4953

5054
[features]
51-
libp2p = ["dep:libp2p"]
55+
libp2p = ["dep:libp2p-identity", "dep:multiaddr"]
5256
serde = ["enr/serde"]

src/discv5.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use tokio::sync::{mpsc, oneshot};
3636
use tracing::{debug, warn};
3737

3838
#[cfg(feature = "libp2p")]
39-
use libp2p::Multiaddr;
39+
use multiaddr::Multiaddr;
4040

4141
// Create lazy static variable for the global permit/ban list
4242
use crate::{

src/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,11 @@ pub use packet::{DefaultProtocolId, ProtocolIdentity};
126126
pub use permit_ban::PermitBanList;
127127
pub use service::TalkRequest;
128128
pub use socket::{ListenConfig, RateLimiter, RateLimiterBuilder};
129-
// re-export the ENR crate
129+
// Re-export the ENR crate
130130
pub use enr;
131+
132+
// Re-export libp2p-identity and multiaddr
133+
#[cfg(feature = "libp2p")]
134+
pub use libp2p_identity;
135+
#[cfg(feature = "libp2p")]
136+
pub use multiaddr;

src/node_info.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ use enr::{CombinedPublicKey, NodeId};
44
use std::net::SocketAddr;
55

66
#[cfg(feature = "libp2p")]
7-
use libp2p::{
8-
identity::{KeyType, PublicKey},
9-
multiaddr::Protocol,
10-
Multiaddr,
11-
};
7+
use libp2p_identity::{KeyType, PublicKey};
8+
#[cfg(feature = "libp2p")]
9+
use multiaddr::{Multiaddr, Protocol};
1210

1311
/// This type relaxes the requirement of having an ENR to connect to a node, to allow for unsigned
1412
/// connection types, such as multiaddrs.

0 commit comments

Comments
 (0)