Skip to content

Commit

Permalink
Revert "Make the SwarmEvent report everything (libp2p#1515)"
Browse files Browse the repository at this point in the history
This reverts commit 7220877
  • Loading branch information
folex committed Mar 30, 2020
1 parent 39e109f commit f268f67
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 176 deletions.
3 changes: 1 addition & 2 deletions core/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ use fnv::{FnvHashMap};
use futures::{prelude::*, future};
use std::{
collections::hash_map,
convert::TryFrom as _,
error,
fmt,
hash::Hash,
Expand Down Expand Up @@ -518,7 +517,7 @@ where
// A pending outgoing connection to a known peer failed.
let mut attempt = dialing.remove(&peer_id).expect("by (1)");

let num_remain = u32::try_from(attempt.next.len()).unwrap();
let num_remain = attempt.next.len();
let failed_addr = attempt.current.clone();

let opts =
Expand Down
13 changes: 6 additions & 7 deletions core/src/network/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::{
transport::{Transport, TransportError},
};
use futures::prelude::*;
use std::{error, fmt, hash::Hash, num::NonZeroU32};
use std::{error, fmt, hash::Hash};

/// Event that can happen on the `Network`.
pub enum NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>
Expand Down Expand Up @@ -88,7 +88,7 @@ where
/// A new connection arrived on a listener.
IncomingConnection(IncomingConnectionEvent<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>),

/// An error happened on a connection during its initial handshake.
/// A new connection was arriving on a listener, but an error happened when negotiating it.
///
/// This can include, for example, an error during the handshake of the encryption layer, or
/// the connection unexpectedly closed.
Expand All @@ -105,9 +105,8 @@ where
ConnectionEstablished {
/// The newly established connection.
connection: EstablishedConnection<'a, TInEvent, TConnInfo, TPeerId>,
/// The total number of established connections to the same peer, including the one that
/// has just been opened.
num_established: NonZeroU32,
/// The total number of established connections to the same peer.
num_established: usize,
},

/// An established connection to a peer has encountered an error.
Expand All @@ -119,13 +118,13 @@ where
/// The error that occurred.
error: ConnectionError<<THandler::Handler as ConnectionHandler>::Error>,
/// The remaining number of established connections to the same peer.
num_established: u32,
num_established: usize,
},

/// A dialing attempt to an address of a peer failed.
DialError {
/// The number of remaining dialing attempts.
attempts_remaining: u32,
attempts_remaining: usize,

/// Id of the peer we were trying to dial.
peer_id: TPeerId,
Expand Down
2 changes: 1 addition & 1 deletion core/tests/network_dial_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ fn multiple_addresses_err() {
assert_eq!(attempts_remaining, 0);
return Poll::Ready(Ok(()));
} else {
assert_eq!(attempts_remaining, addresses.len() as u32);
assert_eq!(attempts_remaining, addresses.len());
}
},
Poll::Ready(_) => unreachable!(),
Expand Down
Loading

0 comments on commit f268f67

Please sign in to comment.