Skip to content

Commit c5bcada

Browse files
AgeManningmxinden
andauthored
protocols/gossipsub: Rework connection keep-alive (#2043)
Keep connections to peers in a mesh alive. Allow closing idle connections to peers not in a mesh. Co-authored-by: Max Inden <[email protected]>
1 parent 9c5dd84 commit c5bcada

File tree

9 files changed

+584
-248
lines changed

9 files changed

+584
-248
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ futures = "0.3.1"
6666
lazy_static = "1.2"
6767
libp2p-core = { version = "0.28.3", path = "core", default-features = false }
6868
libp2p-floodsub = { version = "0.29.0", path = "protocols/floodsub", optional = true }
69-
libp2p-gossipsub = { version = "0.30.1", path = "./protocols/gossipsub", optional = true }
69+
libp2p-gossipsub = { version = "0.31.0", path = "./protocols/gossipsub", optional = true }
7070
libp2p-identify = { version = "0.29.0", path = "protocols/identify", optional = true }
7171
libp2p-kad = { version = "0.30.0", path = "protocols/kad", optional = true }
7272
libp2p-mplex = { version = "0.28.0", path = "muxers/mplex", optional = true }

examples/gossipsub-chat.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
116116
};
117117

118118
// Listen on all interfaces and whatever port the OS assigns
119-
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap()).unwrap();
119+
swarm
120+
.listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap())
121+
.unwrap();
120122

121123
// Reach out to another node if specified
122124
if let Some(to_dial) = std::env::args().nth(1) {
@@ -138,7 +140,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
138140
task::block_on(future::poll_fn(move |cx: &mut Context<'_>| {
139141
loop {
140142
if let Err(e) = match stdin.try_poll_next_unpin(cx)? {
141-
Poll::Ready(Some(line)) => swarm.behaviour_mut().publish(topic.clone(), line.as_bytes()),
143+
Poll::Ready(Some(line)) => swarm
144+
.behaviour_mut()
145+
.publish(topic.clone(), line.as_bytes()),
142146
Poll::Ready(None) => panic!("Stdin closed"),
143147
Poll::Pending => break,
144148
} {

protocols/gossipsub/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 0.31.0 [unreleased]
2+
3+
- Keep connections to peers in a mesh alive. Allow closing idle connections to peers not in a mesh
4+
[PR-2043].
5+
6+
[PR-2043]: https://github.com/libp2p/rust-libp2p/pull/2043https://github.com/libp2p/rust-libp2p/pull/2043
7+
18
# 0.30.1 [2021-04-27]
29

310
- Remove `regex-filter` feature flag thus always enabling `regex::RegexSubscriptionFilter` [PR

protocols/gossipsub/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "libp2p-gossipsub"
33
edition = "2018"
44
description = "Gossipsub protocol for libp2p"
5-
version = "0.30.1"
5+
version = "0.31.0"
66
authors = ["Age Manning <[email protected]>"]
77
license = "MIT"
88
repository = "https://github.com/libp2p/rust-libp2p"

0 commit comments

Comments
 (0)