mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
Ensure any call to disable peer has a reason (#321)
* Fix warnings in libp2p * Force a reason when you use the fatalist disable_peer * Print more information * Slightly more concise ref-fu * Tracing for figuring out what's going into genesis * Merge * Fxi test
This commit is contained in:
@@ -355,7 +355,7 @@ impl PolkadotProtocol {
|
||||
};
|
||||
|
||||
if !info.validator {
|
||||
ctx.disable_peer(peer_id);
|
||||
ctx.disable_peer(peer_id, "Unknown Polkadot-protocol reason");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ impl PolkadotProtocol {
|
||||
self.pending.push(req);
|
||||
self.dispatch_pending_requests(ctx);
|
||||
}
|
||||
None => ctx.disable_peer(peer_id),
|
||||
None => ctx.disable_peer(peer_id, "Unknown Polkadot-protocol reason"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,7 +415,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
|
||||
if let Some((ref acc_id, ref para_id)) = local_status.collating_for {
|
||||
if self.collator_peer_id(acc_id.clone()).is_some() {
|
||||
ctx.disable_peer(peer_id);
|
||||
ctx.disable_peer(peer_id, "Unknown Polkadot-protocol reason");
|
||||
return
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
Ok(msg) => self.on_polkadot_message(ctx, peer_id, raw, msg),
|
||||
Err(e) => {
|
||||
trace!(target: "p_net", "Bad message from {}: {}", peer_id, e);
|
||||
ctx.disable_peer(peer_id);
|
||||
ctx.disable_peer(peer_id, "Unknown Polkadot-protocol reason");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -546,13 +546,13 @@ impl PolkadotProtocol {
|
||||
match self.peers.get(&from) {
|
||||
None => ctx.disconnect_peer(from),
|
||||
Some(peer_info) => match peer_info.status.collating_for {
|
||||
None => ctx.disable_peer(from),
|
||||
None => ctx.disable_peer(from, "Unknown Polkadot-protocol reason"),
|
||||
Some((ref acc_id, ref para_id)) => {
|
||||
let structurally_valid = para_id == &collation_para && acc_id == &collated_acc;
|
||||
if structurally_valid && collation.receipt.check_signature().is_ok() {
|
||||
self.collators.on_collation(acc_id.clone(), relay_parent, collation)
|
||||
} else {
|
||||
ctx.disable_peer(from)
|
||||
ctx.disable_peer(from, "Unknown Polkadot-protocol reason")
|
||||
};
|
||||
}
|
||||
},
|
||||
@@ -583,7 +583,7 @@ impl PolkadotProtocol {
|
||||
// disconnect a collator by account-id.
|
||||
fn disconnect_bad_collator(&self, ctx: &mut Context<Block>, account_id: AccountId) {
|
||||
if let Some(peer_id) = self.collator_peer_id(account_id) {
|
||||
ctx.disable_peer(peer_id)
|
||||
ctx.disable_peer(peer_id, "Unknown Polkadot-protocol reason")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ impl Context<Block> for TestContext {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn disable_peer(&mut self, peer: PeerId) {
|
||||
fn disable_peer(&mut self, peer: PeerId, _reason: &str) {
|
||||
self.disabled.push(peer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user