Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove circular dependencies across workspace #3023

Merged
merged 58 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3114d50
Move derive tests to `libp2p-swarm`
thomaseizinger Oct 23, 2022
d6625cb
Introduce `derive_prelude`
thomaseizinger Oct 23, 2022
3eec1fc
Extract `parse_attribute_value_by_key`
thomaseizinger Oct 23, 2022
16a856c
Introduce `prelude` configuration option for `NetworkBehaviour` macro
thomaseizinger Oct 24, 2022
bd77e1d
Move `NetworkBehaviour` macro export from `libp2p` to `libp2p_swarm`
thomaseizinger Oct 24, 2022
e97f150
Rename tests to make it clear what they are
thomaseizinger Oct 24, 2022
1c8654e
Sort feature alphabetically
thomaseizinger Oct 24, 2022
8a5edfa
Feature-gate `NetworkBehaviour` custom derive
thomaseizinger Oct 24, 2022
7d74261
Don't depend on the meta crate for dev-dependencies
thomaseizinger Oct 14, 2022
9b70a61
Deprecate development transports
thomaseizinger Oct 24, 2022
372ee73
Merge branch '3053-deprecate-development-transport' into 2173-no-libp…
thomaseizinger Oct 24, 2022
9bc9cff
Activate all features for examples
thomaseizinger Oct 24, 2022
08622ac
Merge branch 'master' into 3053-move-swarm-derive
thomaseizinger Oct 24, 2022
86d6065
Merge branch '3053-move-swarm-derive' into 2173-no-libp2p-dev-dependency
thomaseizinger Oct 24, 2022
c5047b6
Merge branch 'master' into 3053-move-swarm-derive
thomaseizinger Oct 24, 2022
a99823f
Set PR number in changelog
thomaseizinger Oct 24, 2022
131945b
Fmt
thomaseizinger Oct 24, 2022
7b0943b
Set correct version in changelog
thomaseizinger Oct 24, 2022
5d7891b
Merge branch '3053-move-swarm-derive' into 2173-no-libp2p-dev-dependency
thomaseizinger Oct 24, 2022
cf53736
Fix doc tests
thomaseizinger Oct 24, 2022
5e2eaac
Merge branch '3053-move-swarm-derive' into 2173-no-libp2p-dev-dependency
thomaseizinger Oct 24, 2022
bcf8a24
Merge branch 'master' into 2173-no-libp2p-dev-dependency
thomaseizinger Nov 13, 2022
04b4cc1
Undo merge errors
thomaseizinger Nov 13, 2022
86355e1
Resolve compile errors
thomaseizinger Nov 13, 2022
3760ab4
Allow clippy lint
thomaseizinger Nov 13, 2022
8077c1a
Fix cfgs
thomaseizinger Nov 13, 2022
02a594c
Activate necessary feature
thomaseizinger Nov 14, 2022
09ae6b2
Merge remote-tracking branch 'origin/master' into 2173-no-libp2p-dev-…
thomaseizinger Nov 14, 2022
455833a
Remove `libp2p` dev-dependency from `quic` and `tls`
thomaseizinger Nov 14, 2022
525bf71
Merge branch 'master' into 2173-no-libp2p-dev-dependency
thomaseizinger Nov 16, 2022
6270a23
Don't deprecate development transports
thomaseizinger Nov 18, 2022
8bf4d22
Merge branch 'master' into 2173-no-libp2p-dev-dependency
thomaseizinger Nov 18, 2022
9a711c5
Remove `libp2p` dependency from webrtc
thomaseizinger Nov 18, 2022
d1595d0
Fix features in `multistream-select`
thomaseizinger Nov 18, 2022
47df28a
Merge branch 'master' into 2173-no-libp2p-dev-dependency
thomaseizinger Nov 19, 2022
6b329fd
Fix missing features in dev-dependencies
thomaseizinger Nov 21, 2022
d8111d2
Add CI check to enforce no dependency on `libp2p`
thomaseizinger Nov 21, 2022
d9f58f9
Revert changes to root examples
thomaseizinger Nov 21, 2022
6ca722f
Remove dbg
thomaseizinger Nov 21, 2022
90ef917
Fix clippy beta lint
thomaseizinger Nov 21, 2022
2969c3b
Fix gossipsub doc tests
thomaseizinger Nov 22, 2022
11de29c
Use correct transport
thomaseizinger Nov 22, 2022
c56b844
Fix gossipsub docs
thomaseizinger Nov 22, 2022
8a32da8
Merge branch 'master' into 2173-no-libp2p-dev-dependency
thomaseizinger Nov 22, 2022
9b1bafe
Merge branch 'master' into 2173-no-libp2p-dev-dependency
thomaseizinger Nov 23, 2022
0625380
Merge branch '2173-no-libp2p-dev-dependency' of github.com:libp2p/rus…
thomaseizinger Nov 23, 2022
122e36f
Tidy up imports
thomaseizinger Nov 23, 2022
e39f620
Merge branch 'master' into 2173-no-libp2p-dev-dependency
thomaseizinger Dec 7, 2022
5925f43
Fix unresolved symbol
thomaseizinger Dec 9, 2022
f3b15a5
Merge branch 'master' into 2173-no-libp2p-dev-dependency
thomaseizinger Dec 9, 2022
6324fdb
Merge branch 'master' into 2173-no-libp2p-dev-dependency
mxinden Dec 9, 2022
c5e1a09
Merge branch 'master' into 2173-no-libp2p-dev-dependency
mxinden Dec 9, 2022
cf24170
Implement manual state machines for constant polling
thomaseizinger Dec 12, 2022
f144a7a
Poll transports while connecting
thomaseizinger Dec 12, 2022
a61801a
Merge branch '2173-no-libp2p-dev-dependency' of github.com:libp2p/rus…
thomaseizinger Dec 12, 2022
cd2ada2
Fix clippy
thomaseizinger Dec 12, 2022
4a1229b
Merge branch 'master' into 2173-no-libp2p-dev-dependency
mxinden Dec 12, 2022
374af9e
Merge branch 'master' into 2173-no-libp2p-dev-dependency
mxinden Dec 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ jobs:
cargo install cargo-semver-checks --locked
cargo semver-checks check-release -p ${{ matrix.crate }}

- name: Enforce no dependency on meta crate
run: |
cargo metadata --format-version=1 --no-deps | \
jq -e -r '.packages[] | select(.name == "${{ matrix.crate }}") | .dependencies | all(.name != "libp2p")'
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved

cross:
name: Compile on ${{ matrix.target }}
strategy:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ identify = ["dep:libp2p-identify", "libp2p-metrics?/identify"]
kad = ["dep:libp2p-kad", "libp2p-metrics?/kad"]
macros = ["libp2p-swarm/macros"]
mdns = ["dep:libp2p-mdns"]
tls = ["dep:libp2p-tls"]
metrics = ["dep:libp2p-metrics"]
mplex = ["dep:libp2p-mplex"]
noise = ["dep:libp2p-noise"]
Expand All @@ -76,6 +75,7 @@ rsa = ["libp2p-core/rsa"]
secp256k1 = ["libp2p-core/secp256k1"]
serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"]
tcp = ["dep:libp2p-tcp"]
tls = ["dep:libp2p-tls"]
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-webrtc?/tokio"]
uds = ["dep:libp2p-uds"]
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen"]
Expand Down
3 changes: 2 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ ring = { version = "0.16.9", features = ["alloc", "std"], default-features = fal
async-std = { version = "1.6.2", features = ["attributes"] }
base64 = "0.13.0"
criterion = "0.4"
libp2p = { path = "..", features = ["full"] }
libp2p-mplex = { path = "../muxers/mplex" }
libp2p-noise = { path = "../transports/noise" }
multihash = { version = "0.16", default-features = false, features = ["arb"] }
quickcheck = { package = "quickcheck-ext", path = "../misc/quickcheck-ext" }
rmp-serde = "1.0"
Expand Down
10 changes: 5 additions & 5 deletions core/tests/transport_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
// DEALINGS IN THE SOFTWARE.

use futures::prelude::*;
use libp2p::core::identity;
use libp2p::core::transport::{MemoryTransport, Transport};
use libp2p::core::upgrade::{self, InboundUpgrade, OutboundUpgrade, UpgradeInfo};
use libp2p::mplex::MplexConfig;
use libp2p::noise;
use libp2p_core::identity;
use libp2p_core::transport::{MemoryTransport, Transport};
use libp2p_core::upgrade::{self, InboundUpgrade, OutboundUpgrade, UpgradeInfo};
use libp2p_mplex::MplexConfig;
use libp2p_noise as noise;
use multiaddr::{Multiaddr, Protocol};
use rand::random;
use std::{io, pin::Pin};
Expand Down
12 changes: 10 additions & 2 deletions misc/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ prometheus-client = "0.18.0"
libp2p-gossipsub = { version = "0.43.0", path = "../../protocols/gossipsub", optional = true }

[dev-dependencies]
log = "0.4.0"
env_logger = "0.10.0"
futures = "0.3.1"
libp2p = { path = "../..", features = ["full"] }
hyper = { version="0.14", features = ["server", "tcp", "http1"] }
libp2p-noise = { path = "../../transports/noise" }
libp2p-ping = { path = "../../protocols/ping" }
libp2p-swarm = { path = "../../swarm", features = ["macros"] }
libp2p-tcp = { path = "../../transports/tcp", features = ["async-io"] }
libp2p-yamux = { path = "../../muxers/yamux" }
log = "0.4.0"
tokio = { version = "1", features = ["rt-multi-thread"] }

# Passing arguments to the docsrs builder in order to properly document cfg's.
Expand All @@ -45,3 +49,7 @@ tokio = { version = "1", features = ["rt-multi-thread"] }
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustc-args = ["--cfg", "docsrs"]

[[example]]
name = "metrics"
required-features = ["ping"]
25 changes: 18 additions & 7 deletions misc/metrics/examples/metrics/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@
use env_logger::Env;
use futures::executor::block_on;
use futures::stream::StreamExt;
use libp2p::core::Multiaddr;
use libp2p::metrics::{Metrics, Recorder};
use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
use libp2p::{identify, identity, ping, PeerId, Swarm};
use libp2p_core::{identity, upgrade::Version, Multiaddr, PeerId, Transport};
use libp2p_identify as identify;
use libp2p_metrics::{Metrics, Recorder};
use libp2p_noise as noise;
use libp2p_ping as ping;
use libp2p_swarm::keep_alive;
use libp2p_swarm::NetworkBehaviour;
use libp2p_swarm::Swarm;
use libp2p_swarm::SwarmEvent;
use libp2p_tcp as tcp;
use libp2p_yamux as yamux;
use log::info;
use prometheus_client::registry::Registry;
use std::error::Error;
Expand All @@ -69,10 +75,14 @@ fn main() -> Result<(), Box<dyn Error>> {
let local_key = identity::Keypair::generate_ed25519();
let local_peer_id = PeerId::from(local_key.public());
let local_pub_key = local_key.public();
info!("Local peer id: {:?}", local_peer_id);
info!("Local peer id: {local_peer_id:?}");

let mut swarm = Swarm::without_executor(
block_on(libp2p::development_transport(local_key))?,
tcp::async_io::Transport::default()
.upgrade(Version::V1)
.authenticate(noise::NoiseAuthenticated::xx(&local_key)?)
.multiplex(yamux::YamuxConfig::default())
.boxed(),
Behaviour::new(local_pub_key),
local_peer_id,
);
Expand Down Expand Up @@ -115,14 +125,15 @@ fn main() -> Result<(), Box<dyn Error>> {
/// For illustrative purposes, this includes the [`keep_alive::Behaviour`]) behaviour so the ping actually happen
/// and can be observed via the metrics.
#[derive(NetworkBehaviour)]
#[behaviour(prelude = "libp2p_swarm::derive_prelude")]
struct Behaviour {
identify: identify::Behaviour,
keep_alive: keep_alive::Behaviour,
ping: ping::Behaviour,
}

impl Behaviour {
fn new(local_pub_key: libp2p::identity::PublicKey) -> Self {
fn new(local_pub_key: identity::PublicKey) -> Self {
Self {
ping: ping::Behaviour::default(),
identify: identify::Behaviour::new(identify::Config::new(
Expand Down
5 changes: 4 additions & 1 deletion misc/multistream-select/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ unsigned-varint = "0.7"
[dev-dependencies]
async-std = "1.6.2"
env_logger = "0.10"
libp2p = { path = "../..", features = ["full"] }
libp2p-core = { path = "../../core" }
libp2p-mplex = { path = "../../muxers/mplex" }
libp2p-plaintext = { path = "../../transports/plaintext" }
libp2p-swarm = { path = "../../swarm", features = ["async-std"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }
rand = "0.8"
rw-stream-sink = { version = "0.3.0", path = "../../misc/rw-stream-sink" }
Expand Down
8 changes: 4 additions & 4 deletions misc/multistream-select/tests/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
// DEALINGS IN THE SOFTWARE.

use futures::{channel::oneshot, prelude::*, ready};
use libp2p::core::{
use libp2p_core::{
identity,
multiaddr::Protocol,
muxing::StreamMuxerBox,
transport::{self, MemoryTransport},
upgrade, Multiaddr, PeerId, Transport,
};
use libp2p::mplex::MplexConfig;
use libp2p::plaintext::PlainText2Config;
use libp2p::swarm::{dummy, Swarm, SwarmEvent};
use libp2p_mplex::MplexConfig;
use libp2p_plaintext::PlainText2Config;
use libp2p_swarm::{dummy, Swarm, SwarmEvent};
use rand::random;
use std::task::Poll;

Expand Down
3 changes: 2 additions & 1 deletion muxers/mplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ async-std = { version = "1.7.0", features = ["attributes"] }
criterion = "0.4"
env_logger = "0.10"
futures = "0.3"
libp2p = { path = "../..", features = ["full"] }
libp2p-muxer-test-harness = { path = "../test-harness" }
libp2p-plaintext = { path = "../../transports/plaintext" }
libp2p-tcp = { path = "../../transports/tcp", features = ["async-io"] }
quickcheck = { package = "quickcheck-ext", path = "../../misc/quickcheck-ext" }

[[bench]]
Expand Down
10 changes: 5 additions & 5 deletions muxers/mplex/benches/split_send_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughpu
use futures::future::poll_fn;
use futures::prelude::*;
use futures::{channel::oneshot, future::join};
use libp2p::core::muxing::StreamMuxerExt;
use libp2p::core::{
use libp2p_core::muxing::StreamMuxerExt;
use libp2p_core::{
identity, multiaddr::multiaddr, muxing, transport, upgrade, Multiaddr, PeerId, Transport,
};
use libp2p::plaintext::PlainText2Config;
use libp2p::{mplex, tcp};
use libp2p_mplex as mplex;
use libp2p_plaintext::PlainText2Config;
use std::pin::Pin;
use std::time::Duration;

Expand Down Expand Up @@ -169,7 +169,7 @@ fn tcp_transport(split_send_size: usize) -> BenchTransport {
let mut mplex = mplex::MplexConfig::default();
mplex.set_split_send_size(split_send_size);

tcp::async_io::Transport::new(tcp::Config::default().nodelay(true))
libp2p_tcp::async_io::Transport::new(libp2p_tcp::Config::default().nodelay(true))
.upgrade(upgrade::Version::V1)
.authenticate(PlainText2Config { local_public_key })
.multiplex(mplex)
Expand Down
10 changes: 7 additions & 3 deletions protocols/autonat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ prost = "0.11"

[dev-dependencies]
async-std = { version = "1.10", features = ["attributes"] }
env_logger = "0.10"
clap = { version = "4.0.13", features = ["derive"] }
libp2p = { path = "../..", features = ["full"] }
env_logger = "0.10"
libp2p-identify = { path = "../identify" }
libp2p-noise = { path = "../../transports/noise" }
libp2p-swarm = { path = "../../swarm", features = ["async-std", "macros"] }
libp2p-tcp = { path = "../../transports/tcp", features = ["async-io"] }
libp2p-yamux = { path = "../../muxers/yamux" }

# Passing arguments to the docsrs builder in order to properly document cfg's.
# Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling
[package.metadata.docs.rs]
all-features = true
Expand Down
21 changes: 14 additions & 7 deletions protocols/autonat/examples/autonat_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@

use clap::Parser;
use futures::prelude::*;
use libp2p::autonat;
use libp2p::identify;
use libp2p::multiaddr::Protocol;
use libp2p::swarm::{NetworkBehaviour, Swarm, SwarmEvent};
use libp2p::{identity, Multiaddr, PeerId};
use libp2p_autonat as autonat;
use libp2p_core::multiaddr::Protocol;
use libp2p_core::{identity, upgrade::Version, Multiaddr, PeerId, Transport};
use libp2p_identify as identify;
use libp2p_noise as noise;
use libp2p_swarm::{NetworkBehaviour, Swarm, SwarmEvent};
use libp2p_tcp as tcp;
use libp2p_yamux as yamux;
use std::error::Error;
use std::net::Ipv4Addr;
use std::time::Duration;
Expand Down Expand Up @@ -63,7 +66,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
let local_peer_id = PeerId::from(local_key.public());
println!("Local peer id: {:?}", local_peer_id);

let transport = libp2p::development_transport(local_key.clone()).await?;
let transport = tcp::async_io::Transport::default()
.upgrade(Version::V1)
.authenticate(noise::NoiseAuthenticated::xx(&local_key)?)
.multiplex(yamux::YamuxConfig::default())
.boxed();

let behaviour = Behaviour::new(local_key.public());

Expand All @@ -89,7 +96,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
}

#[derive(NetworkBehaviour)]
#[behaviour(out_event = "Event")]
#[behaviour(out_event = "Event", prelude = "libp2p_swarm::derive_prelude")]
struct Behaviour {
identify: identify::Behaviour,
auto_nat: autonat::Behaviour,
Expand Down
20 changes: 13 additions & 7 deletions protocols/autonat/examples/autonat_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@

use clap::Parser;
use futures::prelude::*;
use libp2p::autonat;
use libp2p::identify;
use libp2p::multiaddr::Protocol;
use libp2p::swarm::{NetworkBehaviour, Swarm, SwarmEvent};
use libp2p::{identity, Multiaddr, PeerId};
use libp2p_autonat as autonat;
use libp2p_core::{identity, multiaddr::Protocol, upgrade::Version, Multiaddr, PeerId, Transport};
use libp2p_identify as identify;
use libp2p_noise as noise;
use libp2p_swarm::{NetworkBehaviour, Swarm, SwarmEvent};
use libp2p_tcp as tcp;
use libp2p_yamux as yamux;
use std::error::Error;
use std::net::Ipv4Addr;

Expand All @@ -53,7 +55,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
let local_peer_id = PeerId::from(local_key.public());
println!("Local peer id: {:?}", local_peer_id);

let transport = libp2p::development_transport(local_key.clone()).await?;
let transport = tcp::async_io::Transport::default()
.upgrade(Version::V1)
.authenticate(noise::NoiseAuthenticated::xx(&local_key)?)
.multiplex(yamux::YamuxConfig::default())
.boxed();

let behaviour = Behaviour::new(local_key.public());

Expand All @@ -74,7 +80,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
}

#[derive(NetworkBehaviour)]
#[behaviour(out_event = "Event")]
#[behaviour(out_event = "Event", prelude = "libp2p_swarm::derive_prelude")]
struct Behaviour {
identify: identify::Behaviour,
auto_nat: autonat::Behaviour,
Expand Down
17 changes: 10 additions & 7 deletions protocols/autonat/tests/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@

use futures::{channel::oneshot, Future, FutureExt, StreamExt};
use futures_timer::Delay;
use libp2p::{
development_transport,
identity::Keypair,
swarm::{AddressScore, Swarm, SwarmEvent},
Multiaddr, PeerId,
};
use libp2p_autonat::{
Behaviour, Config, Event, NatStatus, OutboundProbeError, OutboundProbeEvent, ResponseError,
};
use libp2p_core::{identity::Keypair, upgrade::Version, Multiaddr, PeerId, Transport};
use libp2p_noise as noise;
use libp2p_swarm::{AddressScore, Swarm, SwarmEvent};
use libp2p_tcp as tcp;
use libp2p_yamux as yamux;
use std::time::Duration;

const MAX_CONFIDENCE: usize = 3;
Expand All @@ -38,7 +37,11 @@ const TEST_REFRESH_INTERVAL: Duration = Duration::from_secs(2);
async fn init_swarm(config: Config) -> Swarm<Behaviour> {
let keypair = Keypair::generate_ed25519();
let local_id = PeerId::from_public_key(&keypair.public());
let transport = development_transport(keypair).await.unwrap();
let transport = tcp::async_io::Transport::default()
.upgrade(Version::V1)
.authenticate(noise::NoiseAuthenticated::xx(&keypair).unwrap())
.multiplex(yamux::YamuxConfig::default())
.boxed();
let behaviour = Behaviour::new(local_id, config);
Swarm::with_async_std_executor(transport, behaviour, local_id)
}
Expand Down
24 changes: 14 additions & 10 deletions protocols/autonat/tests/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,28 @@

use futures::{channel::oneshot, Future, FutureExt, StreamExt};
use futures_timer::Delay;
use libp2p::core::{ConnectedPoint, Endpoint};
use libp2p::swarm::DialError;
use libp2p::{
development_transport,
identity::Keypair,
multiaddr::Protocol,
swarm::{AddressScore, Swarm, SwarmEvent},
Multiaddr, PeerId,
};
use libp2p_autonat::{
Behaviour, Config, Event, InboundProbeError, InboundProbeEvent, ResponseError,
};
use libp2p_core::{
identity::Keypair, multiaddr::Protocol, upgrade::Version, ConnectedPoint, Endpoint, Multiaddr,
PeerId, Transport,
};
use libp2p_noise as noise;
use libp2p_swarm::DialError;
use libp2p_swarm::{AddressScore, Swarm, SwarmEvent};
use libp2p_tcp as tcp;
use libp2p_yamux as yamux;
use std::{num::NonZeroU32, time::Duration};

async fn init_swarm(config: Config) -> Swarm<Behaviour> {
let keypair = Keypair::generate_ed25519();
let local_id = PeerId::from_public_key(&keypair.public());
let transport = development_transport(keypair).await.unwrap();
let transport = tcp::async_io::Transport::default()
.upgrade(Version::V1)
.authenticate(noise::NoiseAuthenticated::xx(&keypair).unwrap())
.multiplex(yamux::YamuxConfig::default())
.boxed();
let behaviour = Behaviour::new(local_id, config);
Swarm::with_async_std_executor(transport, behaviour, local_id)
}
Expand Down