Ignore RPC messages of disconnected peers and remove old peers based on disconnection time (#1854)

## Issue Addressed

NA

## Proposed Changes

Lets the networking behavior ignore messages of peers that are not connected. Furthermore, old peers are not removed from the peerdb based on score anymore but based on the disconnection time.
This commit is contained in:
blacktemplar
2020-11-03 23:43:10 +00:00
parent 0a0f4daf9d
commit 7e7fad5734
3 changed files with 26 additions and 13 deletions

View File

@@ -589,6 +589,17 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
fn on_rpc_event(&mut self, message: RPCMessage<TSpec>) {
let peer_id = message.peer_id;
if !self.peer_manager.is_connected(&peer_id) {
//ignore this event
debug!(
self.log,
"Ignoring rpc message of disconnected peer";
"peer" => peer_id.to_string()
);
return;
}
let handler_id = message.conn_id;
// The METADATA and PING RPC responses are handled within the behaviour and not propagated
match message.event {