Use custom type for ProtocolName (#12172)

* Add ProtocolName custom type

* Use new ProtocolName in sc_network_common

* Use new ProtocolName in sc_network

* Use new ProtocolName for BEEFY and GRANDPA

* Use new ProtocolName for notifications

* Use new ProtocolName in sc_network (part 2)

* Use new ProtocolName in sc_network_gossip

* Use new ProtocolName in sc_offchain

* Remove unused imports

* Some more fixes

* Add tests

* Fix minor import issues

* Re-export ProtocolName in sc_network

* Revert "Re-export ProtocolName in sc_network"

This reverts commit 8d8ff71927e7750757f29c9bbd88dc0ba181d214.

* Re-export ProtocolName in sc_network

* Remove dependency on sc-network-common from beefy-gadget
This commit is contained in:
Dmitry Markin
2022-09-03 23:34:47 +03:00
committed by GitHub
parent 09a52ef882
commit 24d09fe8c7
27 changed files with 381 additions and 280 deletions
+8 -11
View File
@@ -328,11 +328,12 @@ mod tests {
use sc_client_db::offchain::LocalStorage;
use sc_network_common::{
config::MultiaddrWithPeerId,
protocol::ProtocolName,
service::{NetworkPeers, NetworkStateInfo},
};
use sc_peerset::ReputationChange;
use sp_core::offchain::{DbExternalities, Externalities};
use std::{borrow::Cow, time::SystemTime};
use std::time::SystemTime;
pub(super) struct TestNetwork();
@@ -353,7 +354,7 @@ mod tests {
unimplemented!();
}
fn disconnect_peer(&self, _who: PeerId, _protocol: Cow<'static, str>) {
fn disconnect_peer(&self, _who: PeerId, _protocol: ProtocolName) {
unimplemented!();
}
@@ -375,7 +376,7 @@ mod tests {
fn set_reserved_peers(
&self,
_protocol: Cow<'static, str>,
_protocol: ProtocolName,
_peers: HashSet<Multiaddr>,
) -> Result<(), String> {
unimplemented!();
@@ -383,29 +384,25 @@ mod tests {
fn add_peers_to_reserved_set(
&self,
_protocol: Cow<'static, str>,
_protocol: ProtocolName,
_peers: HashSet<Multiaddr>,
) -> Result<(), String> {
unimplemented!();
}
fn remove_peers_from_reserved_set(
&self,
_protocol: Cow<'static, str>,
_peers: Vec<PeerId>,
) {
fn remove_peers_from_reserved_set(&self, _protocol: ProtocolName, _peers: Vec<PeerId>) {
unimplemented!();
}
fn add_to_peers_set(
&self,
_protocol: Cow<'static, str>,
_protocol: ProtocolName,
_peers: HashSet<Multiaddr>,
) -> Result<(), String> {
unimplemented!();
}
fn remove_from_peers_set(&self, _protocol: Cow<'static, str>, _peers: Vec<PeerId>) {
fn remove_from_peers_set(&self, _protocol: ProtocolName, _peers: Vec<PeerId>) {
unimplemented!();
}
+8 -12
View File
@@ -249,12 +249,12 @@ mod tests {
use libp2p::{Multiaddr, PeerId};
use sc_block_builder::BlockBuilderProvider as _;
use sc_client_api::Backend as _;
use sc_network_common::config::MultiaddrWithPeerId;
use sc_network_common::{config::MultiaddrWithPeerId, protocol::ProtocolName};
use sc_peerset::ReputationChange;
use sc_transaction_pool::{BasicPool, FullChainApi};
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool};
use sp_consensus::BlockOrigin;
use std::{borrow::Cow, collections::HashSet, sync::Arc};
use std::{collections::HashSet, sync::Arc};
use substrate_test_runtime_client::{
runtime::Block, ClientBlockImportExt, DefaultTestClientBuilderExt, TestClient,
TestClientBuilderExt,
@@ -289,7 +289,7 @@ mod tests {
unimplemented!();
}
fn disconnect_peer(&self, _who: PeerId, _protocol: Cow<'static, str>) {
fn disconnect_peer(&self, _who: PeerId, _protocol: ProtocolName) {
unimplemented!();
}
@@ -311,7 +311,7 @@ mod tests {
fn set_reserved_peers(
&self,
_protocol: Cow<'static, str>,
_protocol: ProtocolName,
_peers: HashSet<Multiaddr>,
) -> Result<(), String> {
unimplemented!();
@@ -319,29 +319,25 @@ mod tests {
fn add_peers_to_reserved_set(
&self,
_protocol: Cow<'static, str>,
_protocol: ProtocolName,
_peers: HashSet<Multiaddr>,
) -> Result<(), String> {
unimplemented!();
}
fn remove_peers_from_reserved_set(
&self,
_protocol: Cow<'static, str>,
_peers: Vec<PeerId>,
) {
fn remove_peers_from_reserved_set(&self, _protocol: ProtocolName, _peers: Vec<PeerId>) {
unimplemented!();
}
fn add_to_peers_set(
&self,
_protocol: Cow<'static, str>,
_protocol: ProtocolName,
_peers: HashSet<Multiaddr>,
) -> Result<(), String> {
unimplemented!();
}
fn remove_from_peers_set(&self, _protocol: Cow<'static, str>, _peers: Vec<PeerId>) {
fn remove_from_peers_set(&self, _protocol: ProtocolName, _peers: Vec<PeerId>) {
unimplemented!();
}