Skip to content

Commit 9a99b3b

Browse files
committed
Squashed commit of the following:
commit 92eaf8a Merge: 5f7f49b a60ffba Author: canewsin <[email protected]> Date: Fri Dec 10 14:55:10 2021 +0530 Merge branch 'relay-v2' of https://github.com/mxinden/rust-libp2p into pr/9 commit a60ffba Author: Max Inden <[email protected]> Date: Thu Dec 9 21:59:03 2021 +0100 protocols/relay/src/v2: Renew reservation after 3/4 of expiration commit bfd92a1 Author: Max Inden <[email protected]> Date: Thu Dec 9 20:42:09 2021 +0100 protocols/relay/src/v2: Fix typo commit 08d6637 Author: Max Inden <[email protected]> Date: Thu Dec 9 20:38:27 2021 +0100 protocols/relay/src/v2: Use OrTransport commit 746c75e Author: Max Inden <[email protected]> Date: Thu Dec 9 15:16:19 2021 +0100 protocols/relay/src/v2/: Document pending_error and send_error_futs commit c0c0880 Author: Max Inden <[email protected]> Date: Thu Dec 9 14:55:20 2021 +0100 protocols/relay/src/v2/client: Extend unreacheable! text commit 5f7f49b Merge: 2de96d6 c88cff1 Author: canewsin <[email protected]> Date: Thu Dec 9 13:23:34 2021 +0530 Merge branch 'relay-v2' into pr/9 commit c88cff1 Author: Max Inden <[email protected]> Date: Mon Nov 1 11:18:58 2021 +0100 Cargo.toml: Remove rc suffix commit 0cf7e96 Author: Max Inden <[email protected]> Date: Mon Nov 1 11:16:59 2021 +0100 *: Prepare v0.40.0 release (libp2p#2323)
1 parent 4fcee3b commit 9a99b3b

File tree

23 files changed

+159
-455
lines changed

23 files changed

+159
-455
lines changed

misc/metrics/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-metrics"
33
edition = "2021"
44
rust-version = "1.56.1"
55
description = "Metrics for libp2p"
6-
version = "0.3.0"
6+
version = "0.1.0"
77
authors = ["Max Inden <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

protocols/gossipsub/CHANGELOG.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
# 0.35.0 [unreleased]
2-
3-
- Update dependencies.
4-
5-
- Migrate to Rust edition 2021 (see [PR 2339]).
6-
7-
[PR 2339]: https://github.com/libp2p/rust-libp2p/pull/2339
8-
9-
# 0.34.0 [2021-11-16]
10-
11-
- Add topic and mesh metrics (see [PR 2316]).
12-
13-
- Fix bug in internal peer's topics tracking (see [PR 2325]).
14-
15-
- Use `instant` and `futures-timer` instead of `wasm-timer` (see [PR 2245]).
16-
17-
- Update dependencies.
18-
19-
[PR 2245]: https://github.com/libp2p/rust-libp2p/pull/2245
20-
[PR 2325]: https://github.com/libp2p/rust-libp2p/pull/2325
21-
[PR 2316]: https://github.com/libp2p/rust-libp2p/pull/2316
22-
231
# 0.33.0 [2021-11-01]
242

253
- Add an event to register peers that do not support the gossipsub protocol

protocols/identify/CHANGELOG.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
# 0.33.0 [unreleased]
2-
3-
- Update dependencies.
4-
5-
- Migrate to Rust edition 2021 (see [PR 2339]).
6-
7-
[PR 2339]: https://github.com/libp2p/rust-libp2p/pull/2339
8-
9-
# 0.32.0 [2021-11-16]
10-
11-
- Use `futures-timer` instead of `wasm-timer` (see [PR 2245]).
12-
- Filter invalid peers from cache used in `addresses_of_peer`[PR 2338].
13-
14-
- Update dependencies.
15-
16-
[PR 2245]: https://github.com/libp2p/rust-libp2p/pull/2245
17-
[PR 2338]: https://github.com/libp2p/rust-libp2p/pull/2338
18-
191
# 0.31.0 [2021-11-01]
202

213
- Make default features of `libp2p-core` optional.

protocols/kad/CHANGELOG.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
# 0.34.0 [unreleased]
2-
3-
- Update dependencies.
4-
5-
- Migrate to Rust edition 2021 (see [PR 2339]).
6-
7-
[PR 2339]: https://github.com/libp2p/rust-libp2p/pull/2339
8-
9-
# 0.33.0 [2021-11-16]
10-
11-
- Use `instant` and `futures-timer` instead of `wasm-timer` (see [PR 2245]).
12-
13-
- Rename `KademliaEvent::InboundRequestServed` to `KademliaEvent::InboundRequest` and move
14-
`InboundPutRecordRequest` into `InboundRequest::PutRecord` and `InboundAddProviderRequest` into
15-
`InboundRequest::AddProvider` (see [PR 2297]).
16-
17-
- Populate the `key` field when converting `KadRequestMsg::PutValue` to `proto::Message` (see [PR 2309]).
18-
19-
- Update dependencies.
20-
21-
[PR 2245]: https://github.com/libp2p/rust-libp2p/pull/2245
22-
[PR 2297]: https://github.com/libp2p/rust-libp2p/pull/2297
23-
[PR 2309]: https://github.com/libp2p/rust-libp2p/pull/2309
24-
251
# 0.32.0 [2021-11-01]
262

273
- Make default features of `libp2p-core` optional.

protocols/relay/CHANGELOG.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
# 0.6.0 [unreleased]
2-
3-
- Update dependencies.
4-
5-
- Migrate to Rust edition 2021 (see [PR 2339]).
6-
7-
[PR 2339]: https://github.com/libp2p/rust-libp2p/pull/2339
8-
9-
# 0.5.0 [2021-11-16]
10-
11-
- Use `instant` instead of `wasm-timer` (see [PR 2245]).
12-
13-
- Update dependencies.
14-
15-
[PR 2245]: https://github.com/libp2p/rust-libp2p/pull/2245
16-
171
# 0.4.0 [2021-11-01]
182

193
- Make default features of `libp2p-core` optional.

protocols/relay/src/v2/client.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! [`NetworkBehaviour`] to act as a circuit relay v2 **client**.
2222
2323
mod handler;
24-
mod transport;
24+
pub mod transport;
2525

2626
use crate::v2::protocol::inbound_stop;
2727
use bytes::Bytes;
@@ -32,7 +32,7 @@ use futures::io::{AsyncRead, AsyncWrite};
3232
use futures::ready;
3333
use futures::stream::StreamExt;
3434
use libp2p_core::connection::{ConnectedPoint, ConnectionId};
35-
use libp2p_core::{Multiaddr, PeerId, Transport};
35+
use libp2p_core::{Multiaddr, PeerId};
3636
use libp2p_swarm::dial_opts::DialOpts;
3737
use libp2p_swarm::{
3838
DialError, NegotiatedSubstream, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler,
@@ -84,11 +84,10 @@ pub struct Client {
8484
}
8585

8686
impl Client {
87-
pub fn new_transport_and_behaviour<T: Transport + Clone>(
87+
pub fn new_transport_and_behaviour(
8888
local_peer_id: PeerId,
89-
transport: T,
90-
) -> (transport::ClientTransport<T>, Self) {
91-
let (transport, from_transport) = transport::ClientTransport::new(transport);
89+
) -> (transport::ClientTransport, Self) {
90+
let (transport, from_transport) = transport::ClientTransport::new();
9291
let behaviour = Client {
9392
local_peer_id,
9493
from_transport,
@@ -323,7 +322,9 @@ impl NetworkBehaviour for Client {
323322
}
324323
Poll::Ready(None) => unreachable!(
325324
"`Relay` `NetworkBehaviour` polled after channel from \
326-
`RelayTransport` has been closed.",
325+
`RelayTransport` has been closed. Unreachable under \
326+
the assumption that the `Client` is never polled after \
327+
`ClientTransport` is dropped.",
327328
),
328329
Poll::Pending => break,
329330
}

protocols/relay/src/v2/client/handler.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub struct Handler {
126126
local_peer_id: PeerId,
127127
remote_peer_id: PeerId,
128128
remote_addr: Multiaddr,
129+
/// A pending fatal error that results in the connection being closed.
129130
pending_error: Option<
130131
ProtocolsHandlerUpgrErr<
131132
EitherError<inbound_stop::UpgradeError, outbound_hop::UpgradeError>,
@@ -158,6 +159,10 @@ pub struct Handler {
158159

159160
circuit_deny_futs: FuturesUnordered<BoxFuture<'static, (PeerId, Result<(), std::io::Error>)>>,
160161

162+
/// Futures that try to send errors to the transport.
163+
///
164+
/// We may drop errors if this handler ends up in a terminal state (by returning
165+
/// [`ProtocolsHandlerEvent::Close`]).
161166
send_error_futs: FuturesUnordered<BoxFuture<'static, ()>>,
162167
}
163168

@@ -392,14 +397,19 @@ impl ProtocolsHandler for Handler {
392397
}
393398
}
394399

395-
self.send_error_futs.push(
396-
async move {
397-
let _ = to_listener
398-
.send(transport::ToListenerMsg::Reservation(Err(())))
399-
.await;
400-
}
401-
.boxed(),
402-
);
400+
if self.pending_error.is_none() {
401+
self.send_error_futs.push(
402+
async move {
403+
let _ = to_listener
404+
.send(transport::ToListenerMsg::Reservation(Err(())))
405+
.await;
406+
}
407+
.boxed(),
408+
);
409+
} else {
410+
// Fatal error occured, thus handler is closing as quickly as possible.
411+
// Transport is notified through dropping `to_listener`.
412+
}
403413

404414
self.queued_events.push_back(ProtocolsHandlerEvent::Custom(
405415
Event::ReservationReqFailed { renewal },

0 commit comments

Comments
 (0)