match self.do_read_event(peer_descriptor, data) {
Ok(res) => Ok(res),
Err(e) => {
+ log_trace!(self.logger, "Peer sent invalid data or we decided to disconnect due to a protocol error");
self.disconnect_event_internal(peer_descriptor, e.no_connection_possible);
Err(e)
}
Some(peer) => {
match peer.their_node_id {
Some(node_id) => {
+ log_trace!(self.logger,
+ "Handling disconnection of peer {}, with {}future connection to the peer possible.",
+ log_pubkey!(node_id), if no_connection_possible { "no " } else { "" });
peers.node_id_to_descriptor.remove(&node_id);
self.message_handler.chan_handler.peer_disconnected(&node_id, no_connection_possible);
},
}
}
- /// This function should be called roughly once every 30 seconds.
- /// It will send pings to each peer and disconnect those which did not respond to the last
- /// round of pings.
+ /// Send pings to each peer and disconnect those which did not respond to the last round of
+ /// pings.
+ ///
+ /// This may be called on any timescale you want, however, roughly once every five to ten
+ /// seconds is preferred. The call rate determines both how often we send a ping to our peers
+ /// and how much time they have to respond before we disconnect them.
///
/// May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy
/// issues!