Skip to content

Commit

Permalink
Merge branch 'master' into kademlia-emit-new-external-addr-of-peer
Browse files Browse the repository at this point in the history
  • Loading branch information
PanGan21 committed Aug 25, 2024
2 parents 8f5a902 + f0cbd4f commit b82fb53
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ jobs:
fail-fast: false
matrix:
rust-version: [
1.78.0, # current stable
1.80.0, # current stable
beta,
]
steps:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ rust-version = "1.75.0"
asynchronous-codec = { version = "0.7.0" }
futures-bounded = { version = "0.2.4" }
futures-rustls = { version = "0.26.0", default-features = false }
libp2p = { version = "0.54.0", path = "libp2p" }
libp2p = { version = "0.54.1", path = "libp2p" }
libp2p-allow-block-list = { version = "0.4.0", path = "misc/allow-block-list" }
libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" }
libp2p-connection-limits = { version = "0.4.0", path = "misc/connection-limits" }
Expand All @@ -89,7 +89,7 @@ libp2p-identity = { version = "0.2.9" }
libp2p-kad = { version = "0.46.1", path = "protocols/kad" }
libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" }
libp2p-memory-connection-limits = { version = "0.3.0", path = "misc/memory-connection-limits" }
libp2p-metrics = { version = "0.14.2", path = "misc/metrics" }
libp2p-metrics = { version = "0.15.0", path = "misc/metrics" }
libp2p-mplex = { version = "0.42.0", path = "muxers/mplex" }
libp2p-noise = { version = "0.45.0", path = "transports/noise" }
libp2p-perf = { version = "0.4.0", path = "protocols/perf" }
Expand Down
2 changes: 1 addition & 1 deletion libp2p/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## 0.54.1

- Update individual crates.
- Update to [`libp2p-kad` `v0.46.1`](protocols/kad/CHANGELOG.md#0461).
- Update to [`libp2p-metrics` `0.15.0`](misc/metrics/CHANGELOG.md#0150).

## 0.54.0

Expand Down
131 changes: 71 additions & 60 deletions libp2p/src/tutorials/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
//! 3. Adding `libp2p` as well as `futures` as dependencies in the
//! `Cargo.toml` file. Current crate versions may be found at
//! [crates.io](https://crates.io/).
//! We will also include `async-std` with the
//! We will also include `tokio` with the
//! "attributes" feature to allow for an `async main`.
//! At the time of writing we have:
//!
Expand All @@ -55,9 +55,9 @@
//! edition = "2021"
//!
//! [dependencies]
//! libp2p = { version = "0.52", features = ["tcp", "tls", "dns", "async-std", "noise", "yamux", "websocket", "ping", "macros"] }
//! futures = "0.3.21"
//! async-std = { version = "1.12.0", features = ["attributes"] }
//! libp2p = { version = "0.54", features = ["noise", "ping", "tcp", "tokio", "yamux"] }
//! futures = "0.3.30"
//! tokio = { version = "1.37.0", features = ["full"] }
//! tracing-subscriber = { version = "0.3", features = ["env-filter"] }
//! ```
//!
Expand All @@ -74,9 +74,11 @@
//! use std::error::Error;
//! use tracing_subscriber::EnvFilter;
//!
//! #[async_std::main]
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error>> {
//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
//! let _ = tracing_subscriber::fmt()
//! .with_env_filter(EnvFilter::from_default_env())
//! .try_init();
//!
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity();
//!
Expand All @@ -89,25 +91,28 @@
//! ## Transport
//!
//! Next up we need to construct a transport. Each transport in libp2p provides encrypted streams.
//! E.g. combining TCP to establish connections, TLS to encrypt these connections and Yamux to run
//! E.g. combining TCP to establish connections, NOISE to encrypt these connections and Yamux to run
//! one or more streams on a connection. Another libp2p transport is QUIC, providing encrypted
//! streams out-of-the-box. We will stick to TCP for now. Each of these implement the [`Transport`]
//! trait.
//!
//! ```rust
//! use std::error::Error;
//! use tracing_subscriber::EnvFilter;
//! use libp2p::{noise, tcp, yamux};
//!
//! #[async_std::main]
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error>> {
//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
//! let _ = tracing_subscriber::fmt()
//! .with_env_filter(EnvFilter::from_default_env())
//! .try_init();
//!
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tokio()
//! .with_tcp(
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! tcp::Config::default(),
//! noise::Config::new,
//! yamux::Config::default,
//! )?;
//!
//! Ok(())
Expand Down Expand Up @@ -137,20 +142,22 @@
//! With the above in mind, let's extend our example, creating a [`ping::Behaviour`](crate::ping::Behaviour) at the end:
//!
//! ```rust
//! use libp2p::ping;
//! use tracing_subscriber::EnvFilter;
//! use std::error::Error;
//! use tracing_subscriber::EnvFilter;
//! use libp2p::{noise, ping, tcp, yamux};
//!
//! #[async_std::main]
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error>> {
//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
//! let _ = tracing_subscriber::fmt()
//! .with_env_filter(EnvFilter::from_default_env())
//! .try_init();
//!
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tokio()
//! .with_tcp(
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! tcp::Config::default(),
//! noise::Config::new,
//! yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?;
//!
Expand All @@ -166,20 +173,22 @@
//! to the [`Transport`] as well as events from the [`Transport`] to the [`NetworkBehaviour`].
//!
//! ```rust
//! use libp2p::ping;
//! use std::error::Error;
//! use tracing_subscriber::EnvFilter;
//! use libp2p::{noise, ping, tcp, yamux};
//!
//! #[async_std::main]
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error>> {
//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
//! let _ = tracing_subscriber::fmt()
//! .with_env_filter(EnvFilter::from_default_env())
//! .try_init();
//!
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tokio()
//! .with_tcp(
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! tcp::Config::default(),
//! noise::Config::new,
//! yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .build();
Expand All @@ -199,24 +208,25 @@
//! Thus, without any other behaviour in place, we would not be able to observe the pings.
//!
//! ```rust
//! use libp2p::ping;
//! use std::error::Error;
//! use std::time::Duration;
//! use std::{error::Error, time::Duration};
//! use tracing_subscriber::EnvFilter;
//! use libp2p::{noise, ping, tcp, yamux};
//!
//! #[async_std::main]
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error>> {
//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
//! let _ = tracing_subscriber::fmt()
//! .with_env_filter(EnvFilter::from_default_env())
//! .try_init();
//!
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tokio()
//! .with_tcp(
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! tcp::Config::default(),
//! noise::Config::new,
//! yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely.
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX)))
//! .build();
//!
//! Ok(())
Expand Down Expand Up @@ -250,24 +260,25 @@
//! remote peer.
//!
//! ```rust
//! use libp2p::{ping, Multiaddr};
//! use std::error::Error;
//! use std::time::Duration;
//! use std::{error::Error, time::Duration};
//! use tracing_subscriber::EnvFilter;
//! use libp2p::{noise, ping, tcp, yamux, Multiaddr};
//!
//! #[async_std::main]
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error>> {
//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
//! let _ = tracing_subscriber::fmt()
//! .with_env_filter(EnvFilter::from_default_env())
//! .try_init();
//!
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tokio()
//! .with_tcp(
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! tcp::Config::default(),
//! noise::Config::new,
//! yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely..
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX)))
//! .build();
//!
//! // Tell the swarm to listen on all interfaces and a random, OS-assigned
Expand All @@ -293,26 +304,26 @@
//! outgoing connection in case we specify an address on the CLI.
//!
//! ```no_run
//! use futures::prelude::*;
//! use libp2p::swarm::SwarmEvent;
//! use libp2p::{ping, Multiaddr};
//! use std::error::Error;
//! use std::time::Duration;
//! use std::{error::Error, time::Duration};
//! use tracing_subscriber::EnvFilter;
//! use libp2p::{noise, ping, tcp, yamux, Multiaddr, swarm::SwarmEvent};
//! use futures::prelude::*;
//!
//! #[async_std::main]
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error>> {
//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
//! let _ = tracing_subscriber::fmt()
//! .with_env_filter(EnvFilter::from_default_env())
//! .try_init();
//!
//! let mut swarm = libp2p::SwarmBuilder::with_new_identity()
//! .with_async_std()
//! .with_tokio()
//! .with_tcp(
//! libp2p::tcp::Config::default(),
//! libp2p::tls::Config::new,
//! libp2p::yamux::Config::default,
//! tcp::Config::default(),
//! noise::Config::new,
//! yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely.
//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX)))
//! .build();
//!
//! // Tell the swarm to listen on all interfaces and a random, OS-assigned
Expand Down
2 changes: 1 addition & 1 deletion misc/metrics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.14.2
## 0.15.0
- Use `web-time` instead of `instant`.
See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347).

Expand Down
2 changes: 1 addition & 1 deletion misc/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-metrics"
edition = "2021"
rust-version = { workspace = true }
description = "Metrics for libp2p"
version = "0.14.2"
version = "0.15.0"
authors = ["Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down

0 comments on commit b82fb53

Please sign in to comment.