Peer scoring updates (#1342)
* Prevent banned peers from interacting with the behaviour * Update smallvec * Add logs * Correct log update
This commit is contained in:
parent
ac2ce2ba6b
commit
025b262e01
@ -798,6 +798,11 @@ impl<TSpec: EthSpec> NetworkBehaviour for Behaviour<TSpec> {
|
|||||||
conn_id: ConnectionId,
|
conn_id: ConnectionId,
|
||||||
event: <Self::ProtocolsHandler as ProtocolsHandler>::OutEvent,
|
event: <Self::ProtocolsHandler as ProtocolsHandler>::OutEvent,
|
||||||
) {
|
) {
|
||||||
|
// All events from banned peers are rejected
|
||||||
|
if self.peer_manager.is_banned(&peer_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
// Events comming from the handler, redirected to each behaviour
|
// Events comming from the handler, redirected to each behaviour
|
||||||
BehaviourHandlerOut::Delegate(delegate) => match *delegate {
|
BehaviourHandlerOut::Delegate(delegate) => match *delegate {
|
||||||
|
@ -178,6 +178,8 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
unban_peer = Some(peer_id.clone());
|
unban_peer = Some(peer_id.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
debug!(self.log, "Peer score adjusted"; "peer_id" => peer_id.to_string(), "score" => info.score.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +293,8 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
/// This adjusts a peer's score based on the error.
|
/// This adjusts a peer's score based on the error.
|
||||||
pub fn handle_rpc_error(&mut self, peer_id: &PeerId, protocol: Protocol, err: &RPCError) {
|
pub fn handle_rpc_error(&mut self, peer_id: &PeerId, protocol: Protocol, err: &RPCError) {
|
||||||
let client = self.network_globals.client(peer_id);
|
let client = self.network_globals.client(peer_id);
|
||||||
warn!(self.log, "RPC Error"; "protocol" => protocol.to_string(), "err" => err.to_string(), "client" => client.to_string());
|
let score = self.network_globals.peers.read().score(peer_id);
|
||||||
|
warn!(self.log, "RPC Error"; "protocol" => protocol.to_string(), "err" => err.to_string(), "client" => client.to_string(), "peer_id" => peer_id.to_string(), "score" => score.to_string());
|
||||||
|
|
||||||
// Map this error to a `PeerAction` (if any)
|
// Map this error to a `PeerAction` (if any)
|
||||||
let peer_action = match err {
|
let peer_action = match err {
|
||||||
|
Loading…
Reference in New Issue
Block a user