mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
fix: Remove circular dependencies across workspace (#3023)
Circular dependencies are problematic in several ways: - They result in cognitive overhead for developers, in trying to figure out what depends on what. - They present `cargo` with limits in what order the crates can be compiled in. - They invalidate build caches unnecessarily thus forcing `cargo` to rebuild certain crates. - They cause problems with tooling such as `release-please`. To actually break the circular dependencies, this patch inlines the uses of `development_transport` in the examples and tests for all sub-crates. This is only meant to be a short-term fix until https://github.com/libp2p/rust-libp2p/issues/3111 and https://github.com/libp2p/rust-libp2p/pull/2888 are fixed. To ensure we don't accidentally reintroduce this dependency, we add a basic CI that queries `cargo metadata` using `jq`. Resolves https://github.com/libp2p/rust-libp2p/issues/3053. Fixes https://github.com/libp2p/rust-libp2p/issues/3223. Related: https://github.com/libp2p/rust-libp2p/pull/2918#discussion_r976514245 Related: https://github.com/googleapis/release-please/issues/1662
This commit is contained in:
@ -22,16 +22,15 @@
|
||||
use clap::Parser;
|
||||
use futures::executor::block_on;
|
||||
use futures::stream::StreamExt;
|
||||
use libp2p::core::upgrade;
|
||||
use libp2p::identify;
|
||||
use libp2p::multiaddr::Protocol;
|
||||
use libp2p::ping;
|
||||
use libp2p::relay::v2::relay::{self, Relay};
|
||||
use libp2p::swarm::{NetworkBehaviour, Swarm, SwarmEvent};
|
||||
use libp2p::tcp;
|
||||
use libp2p::Transport;
|
||||
use libp2p::{identity, PeerId};
|
||||
use libp2p::{noise, Multiaddr};
|
||||
use libp2p_core::multiaddr::Protocol;
|
||||
use libp2p_core::upgrade;
|
||||
use libp2p_core::{identity, Multiaddr, PeerId, Transport};
|
||||
use libp2p_identify as identify;
|
||||
use libp2p_noise as noise;
|
||||
use libp2p_ping as ping;
|
||||
use libp2p_relay::v2::relay::{self, Relay};
|
||||
use libp2p_swarm::{NetworkBehaviour, Swarm, SwarmEvent};
|
||||
use libp2p_tcp as tcp;
|
||||
use std::error::Error;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
|
||||
@ -54,7 +53,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
noise::NoiseAuthenticated::xx(&local_key)
|
||||
.expect("Signing libp2p-noise static DH keypair failed."),
|
||||
)
|
||||
.multiplex(libp2p::yamux::YamuxConfig::default())
|
||||
.multiplex(libp2p_yamux::YamuxConfig::default())
|
||||
.boxed();
|
||||
|
||||
let behaviour = Behaviour {
|
||||
@ -93,7 +92,11 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
|
||||
#[derive(NetworkBehaviour)]
|
||||
#[behaviour(out_event = "Event", event_process = false)]
|
||||
#[behaviour(
|
||||
out_event = "Event",
|
||||
event_process = false,
|
||||
prelude = "libp2p_swarm::derive_prelude"
|
||||
)]
|
||||
struct Behaviour {
|
||||
relay: Relay,
|
||||
ping: ping::Behaviour,
|
||||
|
Reference in New Issue
Block a user