Skip to content

Commit

Permalink
protocols/gossipsub: Rework connection keep-alive (#2043)
Browse files Browse the repository at this point in the history
Keep connections to peers in a mesh alive. Allow closing idle connections to
peers not in a mesh.

Co-authored-by: Max Inden <mail@max-inden.de>
  • Loading branch information
AgeManning and mxinden committed May 14, 2021
1 parent 9c5dd84 commit c5bcada
Show file tree
Hide file tree
Showing 9 changed files with 584 additions and 248 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -66,7 +66,7 @@ futures = "0.3.1"
lazy_static = "1.2"
libp2p-core = { version = "0.28.3", path = "core", default-features = false }
libp2p-floodsub = { version = "0.29.0", path = "protocols/floodsub", optional = true }
libp2p-gossipsub = { version = "0.30.1", path = "./protocols/gossipsub", optional = true }
libp2p-gossipsub = { version = "0.31.0", path = "./protocols/gossipsub", optional = true }
libp2p-identify = { version = "0.29.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.30.0", path = "protocols/kad", optional = true }
libp2p-mplex = { version = "0.28.0", path = "muxers/mplex", optional = true }
Expand Down
8 changes: 6 additions & 2 deletions examples/gossipsub-chat.rs
Expand Up @@ -116,7 +116,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
};

// Listen on all interfaces and whatever port the OS assigns
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()).unwrap();
swarm
.listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap())
.unwrap();

// Reach out to another node if specified
if let Some(to_dial) = std::env::args().nth(1) {
Expand All @@ -138,7 +140,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
task::block_on(future::poll_fn(move |cx: &mut Context<'_>| {
loop {
if let Err(e) = match stdin.try_poll_next_unpin(cx)? {
Poll::Ready(Some(line)) => swarm.behaviour_mut().publish(topic.clone(), line.as_bytes()),
Poll::Ready(Some(line)) => swarm
.behaviour_mut()
.publish(topic.clone(), line.as_bytes()),
Poll::Ready(None) => panic!("Stdin closed"),
Poll::Pending => break,
} {
Expand Down
7 changes: 7 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
@@ -1,3 +1,10 @@
# 0.31.0 [unreleased]

- Keep connections to peers in a mesh alive. Allow closing idle connections to peers not in a mesh
[PR-2043].

[PR-2043]: https://github.com/libp2p/rust-libp2p/pull/2043https://github.com/libp2p/rust-libp2p/pull/2043

# 0.30.1 [2021-04-27]

- Remove `regex-filter` feature flag thus always enabling `regex::RegexSubscriptionFilter` [PR
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/Cargo.toml
Expand Up @@ -2,7 +2,7 @@
name = "libp2p-gossipsub"
edition = "2018"
description = "Gossipsub protocol for libp2p"
version = "0.30.1"
version = "0.31.0"
authors = ["Age Manning <Age@AgeManning.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down

0 comments on commit c5bcada

Please sign in to comment.