mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
update to latest substrate - protocol API update (#130)
* update to latest substrate - protocol API update * nits * remove the wait on a future * use std mpsc for oneshot
This commit is contained in:
committed by
Gav Wood
parent
9fb22ce28d
commit
cdb2faf155
+10
-10
@@ -69,7 +69,7 @@ pub const DOT_PROTOCOL_ID: ::substrate_network::ProtocolId = *b"dot";
|
||||
type FullStatus = GenericFullStatus<Block>;
|
||||
|
||||
/// Specialization of the network service for the polkadot protocol.
|
||||
pub type NetworkService = ::substrate_network::Service<Block, PolkadotProtocol, Hash>;
|
||||
pub type NetworkService = ::substrate_network::Service<Block, PolkadotProtocol>;
|
||||
|
||||
/// Status of a Polkadot node.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
|
||||
@@ -311,7 +311,7 @@ impl PolkadotProtocol {
|
||||
};
|
||||
|
||||
if !info.claimed_validator {
|
||||
ctx.report_peer(who, Severity::Bad("Session key broadcasted without setting authority role"));
|
||||
ctx.report_peer(who, Severity::Bad("Session key broadcasted without setting authority role".to_string()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ impl PolkadotProtocol {
|
||||
self.pending.push(req);
|
||||
self.dispatch_pending_requests(ctx);
|
||||
}
|
||||
None => ctx.report_peer(who, Severity::Bad("Unexpected block data response")),
|
||||
None => ctx.report_peer(who, Severity::Bad("Unexpected block data response".to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ impl PolkadotProtocol {
|
||||
if info.validator_keys.as_slice().is_empty() {
|
||||
ctx.report_peer(
|
||||
who,
|
||||
Severity::Bad("Sent collator role without registering first as validator"),
|
||||
Severity::Bad("Sent collator role without registering first as validator".to_string()),
|
||||
);
|
||||
} else {
|
||||
// update role for all saved session keys for this validator.
|
||||
@@ -419,7 +419,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
|
||||
if let Some((ref acc_id, ref para_id)) = local_status.collating_for {
|
||||
if self.collator_peer(acc_id.clone()).is_some() {
|
||||
ctx.report_peer(who, Severity::Useless("Unknown Polkadot-specific reason"));
|
||||
ctx.report_peer(who, Severity::Useless("Unknown Polkadot-specific reason".to_string()));
|
||||
return
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
Some(msg) => self.on_polkadot_message(ctx, who, msg),
|
||||
None => {
|
||||
trace!(target: "p_net", "Bad message from {}", who);
|
||||
ctx.report_peer(who, Severity::Bad("Invalid polkadot protocol message format"));
|
||||
ctx.report_peer(who, Severity::Bad("Invalid polkadot protocol message format".to_string()));
|
||||
*message = Some(generic_message::Message::ChainSpecific(raw));
|
||||
}
|
||||
}
|
||||
@@ -540,16 +540,16 @@ impl PolkadotProtocol {
|
||||
let collated_acc = collation.receipt.collator;
|
||||
|
||||
match self.peers.get(&from) {
|
||||
None => ctx.report_peer(from, Severity::Useless("Unknown Polkadot specific reason")),
|
||||
None => ctx.report_peer(from, Severity::Useless("Unknown Polkadot specific reason".to_string())),
|
||||
Some(peer_info) => match peer_info.collating_for {
|
||||
None => ctx.report_peer(from, Severity::Bad("Sent collation without registering collator intent")),
|
||||
None => ctx.report_peer(from, Severity::Bad("Sent collation without registering collator intent".to_string())),
|
||||
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() {
|
||||
debug!(target: "p_net", "Received collation for parachain {:?} from peer {}", para_id, from);
|
||||
self.collators.on_collation(acc_id.clone(), relay_parent, collation)
|
||||
} else {
|
||||
ctx.report_peer(from, Severity::Bad("Sent malformed collation"))
|
||||
ctx.report_peer(from, Severity::Bad("Sent malformed collation".to_string()))
|
||||
};
|
||||
}
|
||||
},
|
||||
@@ -580,7 +580,7 @@ impl PolkadotProtocol {
|
||||
// disconnect a collator by account-id.
|
||||
fn disconnect_bad_collator(&mut self, ctx: &mut Context<Block>, account_id: AccountId) {
|
||||
if let Some((who, _)) = self.collator_peer(account_id) {
|
||||
ctx.report_peer(who, Severity::Bad("Consensus layer determined the given collator misbehaved"))
|
||||
ctx.report_peer(who, Severity::Bad("Consensus layer determined the given collator misbehaved".to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user