Skip to content

Commit

Permalink
chore: slim deps (#255)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
onbjerg authored Apr 30, 2024
1 parent 44051ef commit 567da5b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ categories = ["network-programming", "asynchronous"]
exclude = [".gitignore", ".github/*"]

[dependencies]
enr = { version = "0.12", features = ["k256", "ed25519"] }
enr = { version = "0.12", features = ["k256", "ed25519"] }
tokio = { version = "1", features = ["net", "sync", "macros", "rt"] }
libp2p = { version = "0.53", features = ["ed25519", "secp256k1"], optional = true }
libp2p-identity = { version = "0.2", features = [
"ed25519",
"secp256k1",
], optional = true }
multiaddr = { version = "0.18", optional = true }
zeroize = { version = "1", features = ["zeroize_derive"] }
futures = "0.3"
uint = { version = "0.9", default-features = false }
Expand Down Expand Up @@ -48,5 +52,5 @@ tokio = { version = "1", features = ["full"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[features]
libp2p = ["dep:libp2p"]
libp2p = ["dep:libp2p-identity", "dep:multiaddr"]
serde = ["enr/serde"]
2 changes: 1 addition & 1 deletion src/discv5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use tokio::sync::{mpsc, oneshot};
use tracing::{debug, warn};

#[cfg(feature = "libp2p")]
use libp2p::Multiaddr;
use multiaddr::Multiaddr;

// Create lazy static variable for the global permit/ban list
use crate::{
Expand Down
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,11 @@ pub use packet::{DefaultProtocolId, ProtocolIdentity};
pub use permit_ban::PermitBanList;
pub use service::TalkRequest;
pub use socket::{ListenConfig, RateLimiter, RateLimiterBuilder};
// re-export the ENR crate
// Re-export the ENR crate
pub use enr;

// Re-export libp2p-identity and multiaddr
#[cfg(feature = "libp2p")]
pub use libp2p_identity;
#[cfg(feature = "libp2p")]
pub use multiaddr;
8 changes: 3 additions & 5 deletions src/node_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ use enr::{CombinedPublicKey, NodeId};
use std::net::SocketAddr;

#[cfg(feature = "libp2p")]
use libp2p::{
identity::{KeyType, PublicKey},
multiaddr::Protocol,
Multiaddr,
};
use libp2p_identity::{KeyType, PublicKey};
#[cfg(feature = "libp2p")]
use multiaddr::{Multiaddr, Protocol};

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

0 comments on commit 567da5b

Please sign in to comment.