Use custom type for ProtocolName (#5963)

* Use new ProtocolName in peer_set.rs

* Use new ProtocolName for request-response protocols

* Use new ProtocolName in polkadot-network-bridge

* Import and conversion fixes

* Use ProtocolName re-exported in sc_network

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Dmitry Markin
2022-09-04 01:02:01 +03:00
committed by GitHub
parent 3bbfc46d5d
commit b3480bd51f
7 changed files with 224 additions and 229 deletions
@@ -174,12 +174,9 @@ mod tests {
PeerId,
};
use polkadot_primitives::v2::Hash;
use sc_network::{Event as NetworkEvent, IfDisconnected};
use sc_network::{Event as NetworkEvent, IfDisconnected, ProtocolName};
use sp_keyring::Sr25519Keyring;
use std::{
borrow::Cow,
collections::{HashMap, HashSet},
};
use std::collections::{HashMap, HashSet};
fn new_service() -> Service<TestNetwork, TestAuthorityDiscovery> {
let genesis_hash = Hash::repeat_byte(0xff);
@@ -232,18 +229,14 @@ mod tests {
async fn set_reserved_peers(
&mut self,
_protocol: Cow<'static, str>,
_protocol: ProtocolName,
multiaddresses: HashSet<Multiaddr>,
) -> Result<(), String> {
self.peers_set = extract_peer_ids(multiaddresses.into_iter());
Ok(())
}
async fn remove_from_peers_set(
&mut self,
_protocol: Cow<'static, str>,
peers: Vec<PeerId>,
) {
async fn remove_from_peers_set(&mut self, _protocol: ProtocolName, peers: Vec<PeerId>) {
self.peers_set.retain(|elem| !peers.contains(elem));
}
@@ -260,11 +253,11 @@ mod tests {
panic!()
}
fn disconnect_peer(&self, _: PeerId, _: Cow<'static, str>) {
fn disconnect_peer(&self, _: PeerId, _: ProtocolName) {
panic!()
}
fn write_notification(&self, _: PeerId, _: Cow<'static, str>, _: Vec<u8>) {
fn write_notification(&self, _: PeerId, _: ProtocolName, _: Vec<u8>) {
panic!()
}
}