Skip to content

Commit

Permalink
remove stream tracking code in protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
leonzchang committed Oct 13, 2023
1 parent bc07ea9 commit 67750db
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 48 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ libp2p-floodsub = { version = "0.43.0", path = "protocols/floodsub" }
libp2p-gossipsub = { version = "0.45.1", path = "protocols/gossipsub" }
libp2p-identify = { version = "0.43.2", path = "protocols/identify" }
libp2p-identity = { version = "0.2.5" }
libp2p-kad = { version = "0.44.6", path = "protocols/kad" }
libp2p-kad = { version = "0.44.7", path = "protocols/kad" }
libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" }
libp2p-memory-connection-limits = { version = "0.1.0", path = "misc/memory-connection-limits" }
libp2p-metrics = { version = "0.13.1", path = "misc/metrics" }
libp2p-mplex = { version = "0.40.0", path = "muxers/mplex" }
libp2p-muxer-test-harness = { path = "muxers/test-harness" }
libp2p-noise = { version = "0.43.1", path = "transports/noise" }
libp2p-perf = { version = "0.2.0", path = "protocols/perf" }
libp2p-perf = { version = "0.2.1", path = "protocols/perf" }
libp2p-ping = { version = "0.43.2", path = "protocols/ping" }
libp2p-plaintext = { version = "0.40.1", path = "transports/plaintext" }
libp2p-pnet = { version = "0.23.0", path = "transports/pnet" }
libp2p-quic = { version = "0.9.3", path = "transports/quic" }
libp2p-relay = { version = "0.16.1", path = "protocols/relay" }
libp2p-relay = { version = "0.16.2", path = "protocols/relay" }
libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" }
libp2p-upnp = { version = "0.1.1", path = "protocols/upnp" }
libp2p-request-response = { version = "0.25.1", path = "protocols/request-response" }
Expand Down
2 changes: 2 additions & 0 deletions protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 0.44.7 - unreleased

## 0.44.6 - unreleased
- Rename `Kademlia` symbols to follow naming convention.
See [PR 4547].
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-kad"
edition = "2021"
rust-version = { workspace = true }
description = "Kademlia protocol for libp2p"
version = "0.44.6"
version = "0.44.7"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
18 changes: 1 addition & 17 deletions protocols/kad/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ pub struct Handler {
/// List of active inbound substreams with the state they are in.
inbound_substreams: SelectAll<InboundSubstreamState>,

/// Until when to keep the connection alive.
keep_alive: KeepAlive,

/// The connected endpoint of the connection that the handler
/// is associated with.
endpoint: ConnectedPoint,
Expand Down Expand Up @@ -491,8 +488,6 @@ impl Handler {
}
}

let keep_alive = KeepAlive::Until(Instant::now() + idle_timeout);

Handler {
protocol_config,
mode,
Expand All @@ -504,7 +499,6 @@ impl Handler {
outbound_substreams: Default::default(),
num_requested_outbound_streams: 0,
pending_messages: Default::default(),
keep_alive,
protocol_status: ProtocolStatus::Unknown,
remote_supported_protocols: Default::default(),
connection_id,
Expand Down Expand Up @@ -718,7 +712,7 @@ impl ConnectionHandler for Handler {
}

fn connection_keep_alive(&self) -> KeepAlive {
self.keep_alive
KeepAlive::No
}

fn poll(
Expand Down Expand Up @@ -760,16 +754,6 @@ impl ConnectionHandler for Handler {
});
}

let no_streams = self.outbound_substreams.is_empty() && self.inbound_substreams.is_empty();
self.keep_alive = match (no_streams, self.keep_alive) {
// No open streams. Preserve the existing idle timeout.
(true, k @ KeepAlive::Until(_)) => k,
// No open streams. Set idle timeout.
(true, _) => KeepAlive::Until(Instant::now() + self.idle_timeout),
// Keep alive for open streams.
(false, _) => KeepAlive::Yes,
};

Poll::Pending
}

Expand Down
2 changes: 2 additions & 0 deletions protocols/perf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 0.2.1 - unreleased

## 0.2.0

- Raise MSRV to 1.65.
Expand Down
2 changes: 1 addition & 1 deletion protocols/perf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-perf"
edition = "2021"
rust-version = { workspace = true }
description = "libp2p perf protocol implementation"
version = "0.2.0"
version = "0.2.1"
authors = ["Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
17 changes: 1 addition & 16 deletions protocols/perf/src/client/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ pub struct Handler {
requested_streams: VecDeque<Command>,

outbound: FuturesUnordered<BoxFuture<'static, Result<Event, std::io::Error>>>,

keep_alive: KeepAlive,
}

impl Handler {
Expand All @@ -74,7 +72,6 @@ impl Handler {
queued_events: Default::default(),
requested_streams: Default::default(),
outbound: Default::default(),
keep_alive: KeepAlive::Yes,
}
}
}
Expand Down Expand Up @@ -158,7 +155,7 @@ impl ConnectionHandler for Handler {
}

fn connection_keep_alive(&self) -> KeepAlive {
self.keep_alive
KeepAlive::No
}

fn poll(
Expand Down Expand Up @@ -186,18 +183,6 @@ impl ConnectionHandler for Handler {
}
}

if self.outbound.is_empty() {
match self.keep_alive {
KeepAlive::Yes => {
self.keep_alive = KeepAlive::Until(Instant::now() + Duration::from_secs(10));
}
KeepAlive::Until(_) => {}
KeepAlive::No => panic!("Handler never sets KeepAlive::No."),
}
} else {
self.keep_alive = KeepAlive::Yes
}

Poll::Pending
}
}
2 changes: 2 additions & 0 deletions protocols/relay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 0.16.2 - unreleased

## 0.16.1

- Export `RateLimiter` type.
Expand Down
7 changes: 5 additions & 2 deletions protocols/relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name = "libp2p-relay"
edition = "2021"
rust-version = { workspace = true }
description = "Communications relaying for libp2p"
version = "0.16.1"
authors = ["Parity Technologies <admin@parity.io>", "Max Inden <mail@max-inden.de>"]
version = "0.16.2"
authors = [
"Parity Technologies <admin@parity.io>",
"Max Inden <mail@max-inden.de>",
]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
Expand Down
1 change: 0 additions & 1 deletion protocols/relay/src/behaviour/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,6 @@ impl ConnectionHandler for Handler {
if self.reservation_request_future.is_none()
&& self.circuit_accept_futures.is_empty()
&& self.circuit_deny_futures.is_empty()
&& self.alive_lend_out_substreams.is_empty()
&& self.circuits.is_empty()
&& self.active_reservation.is_none()
{
Expand Down
5 changes: 1 addition & 4 deletions protocols/relay/src/priv_client/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,7 @@ impl ConnectionHandler for Handler {
}

// Update keep-alive handling.
if matches!(self.reservation, Reservation::None)
&& self.alive_lend_out_substreams.is_empty()
&& self.circuit_deny_futs.is_empty()
{
if matches!(self.reservation, Reservation::None) && self.circuit_deny_futs.is_empty() {
match self.keep_alive {
KeepAlive::Yes => {
self.keep_alive = KeepAlive::Until(Instant::now() + Duration::from_secs(10));
Expand Down

0 comments on commit 67750db

Please sign in to comment.