Remove necessity to pass ConsensusEngineId when registering notifications protocol (#7549)

* Remove necessity to pass ConsensusEngineId when registering notifications protocol

* Line width

* Fix tests protocol name

* Other renames

* Doc update

* Change issue in TODO
This commit is contained in:
Pierre Krieger
2020-11-18 16:05:35 +01:00
committed by GitHub
parent 22a02d3e7a
commit 1eae9f5792
18 changed files with 228 additions and 284 deletions
@@ -20,7 +20,7 @@
use bytes::Bytes;
use libp2p::core::PeerId;
use libp2p::kad::record::Key;
use sp_runtime::ConsensusEngineId;
use std::borrow::Cow;
/// Events generated by DHT as a response to get_value and put_value requests.
#[derive(Debug, Clone)]
@@ -53,7 +53,7 @@ pub enum Event {
/// Node we opened the substream with.
remote: PeerId,
/// The concerned protocol. Each protocol uses a different substream.
engine_id: ConsensusEngineId,
protocol: Cow<'static, str>,
/// Role of the remote.
role: ObservedRole,
},
@@ -64,7 +64,7 @@ pub enum Event {
/// Node we closed the substream with.
remote: PeerId,
/// The concerned protocol. Each protocol uses a different substream.
engine_id: ConsensusEngineId,
protocol: Cow<'static, str>,
},
/// Received one or more messages from the given node using the given protocol.
@@ -72,7 +72,7 @@ pub enum Event {
/// Node we received the message from.
remote: PeerId,
/// Concerned protocol and associated message.
messages: Vec<(ConsensusEngineId, Bytes)>,
messages: Vec<(Cow<'static, str>, Bytes)>,
},
}
@@ -216,7 +216,7 @@ pub mod generic {
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
pub struct ConsensusMessage {
/// Identifies consensus engine.
pub engine_id: ConsensusEngineId,
pub protocol: ConsensusEngineId,
/// Message payload.
pub data: Vec<u8>,
}