mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-14 18:41:22 +00:00
*: Rework reporting of invalid and wrong PeerIds (#2441)
Previously, the negotiated PeerId was included in the swarm event and inject_dial_failure’s arguments while the expected one was absent. This patch adds the negotiated PeerId to the DialError and includes the expected one in the notifications. Co-authored-by: Roland Kuhn <rk@rkuhn.info>
This commit is contained in:
@ -216,9 +216,12 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
|
||||
libp2p_swarm::DialError::Aborted => {
|
||||
record(OutgoingConnectionErrorError::Aborted)
|
||||
}
|
||||
libp2p_swarm::DialError::InvalidPeerId => {
|
||||
libp2p_swarm::DialError::InvalidPeerId { .. } => {
|
||||
record(OutgoingConnectionErrorError::InvalidPeerId)
|
||||
}
|
||||
libp2p_swarm::DialError::WrongPeerId { .. } => {
|
||||
record(OutgoingConnectionErrorError::WrongPeerId)
|
||||
}
|
||||
libp2p_swarm::DialError::ConnectionIo(_) => {
|
||||
record(OutgoingConnectionErrorError::ConnectionIo)
|
||||
}
|
||||
@ -292,6 +295,7 @@ enum OutgoingConnectionErrorError {
|
||||
DialPeerConditionFalse,
|
||||
Aborted,
|
||||
InvalidPeerId,
|
||||
WrongPeerId,
|
||||
ConnectionIo,
|
||||
TransportMultiaddrNotSupported,
|
||||
TransportOther,
|
||||
@ -304,7 +308,7 @@ struct IncomingConnectionErrorLabels {
|
||||
|
||||
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
|
||||
enum PendingInboundConnectionError {
|
||||
InvalidPeerId,
|
||||
WrongPeerId,
|
||||
TransportErrorMultiaddrNotSupported,
|
||||
TransportErrorOther,
|
||||
Aborted,
|
||||
@ -317,8 +321,8 @@ impl<TTransErr> From<&libp2p_core::connection::PendingInboundConnectionError<TTr
|
||||
{
|
||||
fn from(error: &libp2p_core::connection::PendingInboundConnectionError<TTransErr>) -> Self {
|
||||
match error {
|
||||
libp2p_core::connection::PendingInboundConnectionError::InvalidPeerId => {
|
||||
PendingInboundConnectionError::InvalidPeerId
|
||||
libp2p_core::connection::PendingInboundConnectionError::WrongPeerId { .. } => {
|
||||
PendingInboundConnectionError::WrongPeerId
|
||||
}
|
||||
libp2p_core::connection::PendingInboundConnectionError::ConnectionLimit(_) => {
|
||||
PendingInboundConnectionError::ConnectionLimit
|
||||
|
Reference in New Issue
Block a user