Skip to content

Commit

Permalink
Network: close connection for all discovery errors
Browse files Browse the repository at this point in the history
  • Loading branch information
styppo committed Jan 15, 2025
1 parent 91c35ba commit 4f70084
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions network-libp2p/src/discovery/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use libp2p::{
identity::Keypair,
swarm::{
behaviour::{ConnectionClosed, ConnectionEstablished},
ConnectionDenied, ConnectionId, FromSwarm, NetworkBehaviour, ToSwarm,
CloseConnection, ConnectionDenied, ConnectionId, FromSwarm, NetworkBehaviour, ToSwarm,
},
Multiaddr, PeerId,
};
Expand Down Expand Up @@ -297,8 +297,10 @@ impl NetworkBehaviour for Behaviour {
.push_back(ToSwarm::NewExternalAddrCandidate(observed_address));
}
HandlerOutEvent::Update => self.events.push_back(ToSwarm::GenerateEvent(Event::Update)),
// Errors must not result in a closed connection as light clients are unable to verify ValidatorRecord.
HandlerOutEvent::Error(error) => log::trace!(?error, "Received invalid contact"),
HandlerOutEvent::Error(_) => self.events.push_back(ToSwarm::CloseConnection {
peer_id,
connection: CloseConnection::All,
}),
}
}
}

0 comments on commit 4f70084

Please sign in to comment.