Specialization::on_message now takes Vec<u8> (#3054)

This commit is contained in:
Pierre Krieger
2019-07-08 15:34:05 +02:00
committed by Gavin Wood
parent 1e126eab2f
commit 3a002a9100
3 changed files with 6 additions and 5 deletions
+3 -2
View File
@@ -576,6 +576,7 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
self.on_finality_proof_request(who, request),
GenericMessage::FinalityProofResponse(response) =>
return self.on_finality_proof_response(who, response),
GenericMessage::RemoteReadChildRequest(_) => {}
GenericMessage::Consensus(msg) => {
if self.context_data.peers.get(&who).map_or(false, |peer| peer.info.protocol_version > 2) {
self.consensus_gossip.on_incoming(
@@ -585,10 +586,10 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
);
}
}
other => self.specialization.on_message(
GenericMessage::ChainSpecific(msg) => self.specialization.on_message(
&mut ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle),
who,
&mut Some(other),
msg,
),
}
@@ -38,7 +38,7 @@ pub trait NetworkSpecialization<B: BlockT>: Send + Sync + 'static {
&mut self,
ctx: &mut dyn Context<B>,
who: PeerId,
message: &mut Option<crate::message::Message<B>>
message: Vec<u8>
);
/// Called when a network-specific event arrives.
@@ -130,7 +130,7 @@ macro_rules! construct_simple_protocol {
&mut self,
_ctx: &mut $crate::Context<$block>,
_who: $crate::PeerId,
_message: &mut Option<$crate::message::Message<$block>>
_message: Vec<u8>,
) {
$( self.$sub_protocol_name.on_message(_ctx, _who, _message); )*
}
+1 -1
View File
@@ -114,7 +114,7 @@ impl NetworkSpecialization<Block> for DummySpecialization {
&mut self,
_ctx: &mut dyn Context<Block>,
_peer_id: PeerId,
_message: &mut Option<crate::message::Message<Block>>,
_message: Vec<u8>,
) {}
fn on_event(