Skip to content

Commit c931771

Browse files
committed
remove stream tracking code in protocols
1 parent 1322ff3 commit c931771

File tree

12 files changed

+22
-48
lines changed

12 files changed

+22
-48
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ libp2p-floodsub = { version = "0.43.0", path = "protocols/floodsub" }
8484
libp2p-gossipsub = { version = "0.45.1", path = "protocols/gossipsub" }
8585
libp2p-identify = { version = "0.43.2", path = "protocols/identify" }
8686
libp2p-identity = { version = "0.2.5" }
87-
libp2p-kad = { version = "0.44.6", path = "protocols/kad" }
87+
libp2p-kad = { version = "0.44.7", path = "protocols/kad" }
8888
libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" }
8989
libp2p-memory-connection-limits = { version = "0.1.0", path = "misc/memory-connection-limits" }
9090
libp2p-metrics = { version = "0.13.1", path = "misc/metrics" }
9191
libp2p-mplex = { version = "0.40.0", path = "muxers/mplex" }
9292
libp2p-muxer-test-harness = { path = "muxers/test-harness" }
9393
libp2p-noise = { version = "0.43.1", path = "transports/noise" }
94-
libp2p-perf = { version = "0.2.0", path = "protocols/perf" }
94+
libp2p-perf = { version = "0.2.1", path = "protocols/perf" }
9595
libp2p-ping = { version = "0.43.2", path = "protocols/ping" }
9696
libp2p-plaintext = { version = "0.40.1", path = "transports/plaintext" }
9797
libp2p-pnet = { version = "0.23.0", path = "transports/pnet" }
9898
libp2p-quic = { version = "0.9.2", path = "transports/quic" }
99-
libp2p-relay = { version = "0.16.1", path = "protocols/relay" }
99+
libp2p-relay = { version = "0.16.2", path = "protocols/relay" }
100100
libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" }
101101
libp2p-upnp = { version = "0.1.1", path = "protocols/upnp" }
102102
libp2p-request-response = { version = "0.25.1", path = "protocols/request-response" }

protocols/kad/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 0.44.7 - unreleased
2+
13
## 0.44.6 - unreleased
24
- Rename `Kademlia` symbols to follow naming convention.
35
See [PR 4547].

protocols/kad/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-kad"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "Kademlia protocol for libp2p"
6-
version = "0.44.6"
6+
version = "0.44.7"
77
authors = ["Parity Technologies <admin@parity.io>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

protocols/kad/src/handler.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ pub struct Handler {
7979
/// List of active inbound substreams with the state they are in.
8080
inbound_substreams: SelectAll<InboundSubstreamState>,
8181

82-
/// Until when to keep the connection alive.
83-
keep_alive: KeepAlive,
84-
8582
/// The connected endpoint of the connection that the handler
8683
/// is associated with.
8784
endpoint: ConnectedPoint,
@@ -491,8 +488,6 @@ impl Handler {
491488
}
492489
}
493490

494-
let keep_alive = KeepAlive::Until(Instant::now() + idle_timeout);
495-
496491
Handler {
497492
protocol_config,
498493
mode,
@@ -504,7 +499,6 @@ impl Handler {
504499
outbound_substreams: Default::default(),
505500
num_requested_outbound_streams: 0,
506501
pending_messages: Default::default(),
507-
keep_alive,
508502
protocol_status: ProtocolStatus::Unknown,
509503
remote_supported_protocols: Default::default(),
510504
connection_id,
@@ -718,7 +712,7 @@ impl ConnectionHandler for Handler {
718712
}
719713

720714
fn connection_keep_alive(&self) -> KeepAlive {
721-
self.keep_alive
715+
KeepAlive::No
722716
}
723717

724718
fn poll(
@@ -760,16 +754,6 @@ impl ConnectionHandler for Handler {
760754
});
761755
}
762756

763-
let no_streams = self.outbound_substreams.is_empty() && self.inbound_substreams.is_empty();
764-
self.keep_alive = match (no_streams, self.keep_alive) {
765-
// No open streams. Preserve the existing idle timeout.
766-
(true, k @ KeepAlive::Until(_)) => k,
767-
// No open streams. Set idle timeout.
768-
(true, _) => KeepAlive::Until(Instant::now() + self.idle_timeout),
769-
// Keep alive for open streams.
770-
(false, _) => KeepAlive::Yes,
771-
};
772-
773757
Poll::Pending
774758
}
775759

protocols/perf/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 0.2.1 - unreleased
2+
13
## 0.2.0
24

35
- Raise MSRV to 1.65.

protocols/perf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-perf"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "libp2p perf protocol implementation"
6-
version = "0.2.0"
6+
version = "0.2.1"
77
authors = ["Max Inden <mail@max-inden.de>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

protocols/perf/src/client/handler.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ pub struct Handler {
6464
requested_streams: VecDeque<Command>,
6565

6666
outbound: FuturesUnordered<BoxFuture<'static, Result<Event, std::io::Error>>>,
67-
68-
keep_alive: KeepAlive,
6967
}
7068

7169
impl Handler {
@@ -74,7 +72,6 @@ impl Handler {
7472
queued_events: Default::default(),
7573
requested_streams: Default::default(),
7674
outbound: Default::default(),
77-
keep_alive: KeepAlive::Yes,
7875
}
7976
}
8077
}
@@ -158,7 +155,7 @@ impl ConnectionHandler for Handler {
158155
}
159156

160157
fn connection_keep_alive(&self) -> KeepAlive {
161-
self.keep_alive
158+
KeepAlive::No
162159
}
163160

164161
fn poll(
@@ -186,18 +183,6 @@ impl ConnectionHandler for Handler {
186183
}
187184
}
188185

189-
if self.outbound.is_empty() {
190-
match self.keep_alive {
191-
KeepAlive::Yes => {
192-
self.keep_alive = KeepAlive::Until(Instant::now() + Duration::from_secs(10));
193-
}
194-
KeepAlive::Until(_) => {}
195-
KeepAlive::No => panic!("Handler never sets KeepAlive::No."),
196-
}
197-
} else {
198-
self.keep_alive = KeepAlive::Yes
199-
}
200-
201186
Poll::Pending
202187
}
203188
}

protocols/relay/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 0.16.2 - unreleased
2+
13
## 0.16.1
24

35
- Export `RateLimiter` type.

protocols/relay/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ name = "libp2p-relay"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "Communications relaying for libp2p"
6-
version = "0.16.1"
7-
authors = ["Parity Technologies <admin@parity.io>", "Max Inden <mail@max-inden.de>"]
6+
version = "0.16.2"
7+
authors = [
8+
"Parity Technologies <admin@parity.io>",
9+
"Max Inden <mail@max-inden.de>",
10+
]
811
license = "MIT"
912
repository = "https://github.com/libp2p/rust-libp2p"
1013
keywords = ["peer-to-peer", "libp2p", "networking"]

0 commit comments

Comments
 (0)