Update for new peerset API (#644)

* Reputation changes require reason

* Fixes

* Bump version
This commit is contained in:
Arkadiy Paronyan
2019-12-03 12:09:05 +01:00
committed by Gavin Wood
parent 72bfa8c615
commit 7cb57e7ab6
23 changed files with 230 additions and 219 deletions
+16 -13
View File
@@ -54,23 +54,26 @@ use crate::gossip::{POLKADOT_ENGINE_ID, GossipMessage};
mod tests;
mod cost {
pub(super) const UNEXPECTED_MESSAGE: i32 = -200;
pub(super) const INVALID_FORMAT: i32 = -200;
use sc_network::ReputationChange as Rep;
pub(super) const UNEXPECTED_MESSAGE: Rep = Rep::new(-200, "Polkadot: Unexpected message");
pub(super) const UNEXPECTED_ROLE: Rep = Rep::new(-200, "Polkadot: Unexpected role");
pub(super) const INVALID_FORMAT: Rep = Rep::new(-200, "Polkadot: Bad message");
pub(super) const UNKNOWN_PEER: i32 = -50;
pub(super) const COLLATOR_ALREADY_KNOWN: i32 = -100;
pub(super) const BAD_COLLATION: i32 = -1000;
pub(super) const BAD_POV_BLOCK: i32 = -1000;
pub(super) const UNKNOWN_PEER: Rep = Rep::new(-50, "Polkadot: Unknown peer");
pub(super) const COLLATOR_ALREADY_KNOWN: Rep = Rep::new( -100, "Polkadot: Known collator");
pub(super) const BAD_COLLATION: Rep = Rep::new(-1000, "Polkadot: Bad collation");
pub(super) const BAD_POV_BLOCK: Rep = Rep::new(-1000, "Polkadot: Bad POV block");
}
mod benefit {
pub(super) const EXPECTED_MESSAGE: i32 = 20;
pub(super) const VALID_FORMAT: i32 = 20;
use sc_network::ReputationChange as Rep;
pub(super) const EXPECTED_MESSAGE: Rep = Rep::new(20, "Polkadot: Expected message");
pub(super) const VALID_FORMAT: Rep = Rep::new(20, "Polkadot: Valid message format");
pub(super) const KNOWN_PEER: i32 = 5;
pub(super) const NEW_COLLATOR: i32 = 10;
pub(super) const GOOD_COLLATION: i32 = 100;
pub(super) const GOOD_POV_BLOCK: i32 = 100;
pub(super) const KNOWN_PEER: Rep = Rep::new(5, "Polkadot: Known peer");
pub(super) const NEW_COLLATOR: Rep = Rep::new(10, "Polkadot: New collator");
pub(super) const GOOD_COLLATION: Rep = Rep::new(100, "Polkadot: Good collation");
pub(super) const GOOD_POV_BLOCK: Rep = Rep::new(100, "Polkadot: Good POV block");
}
type FullStatus = GenericFullStatus<Block>;
@@ -553,7 +556,7 @@ impl PolkadotProtocol {
debug!(target: "p_net", "New collator role {:?} from {}", role, who);
if info.validator_keys.as_slice().is_empty() {
ctx.report_peer(who, cost::UNEXPECTED_MESSAGE);
ctx.report_peer(who, cost::UNEXPECTED_ROLE)
} else {
// update role for all saved session keys for this validator.
let local_collations = &mut self.local_collations;