Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Start using NetworkService traits from sc-network
  • Loading branch information
altonen committed Mar 13, 2023
commit 2a0188d719e7f4e04a6b3b8bd6ec8097c56586cf
14 changes: 6 additions & 8 deletions node/network/bridge/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ use futures::{prelude::*, stream::BoxStream};
use parity_scale_codec::Encode;

use sc_network::{
multiaddr::Multiaddr, Event as NetworkEvent, IfDisconnected, NetworkService, OutboundFailure,
multiaddr::Multiaddr, Event as NetworkEvent, IfDisconnected, NetworkEventStream,
NetworkNotification, NetworkPeers, NetworkRequest, NetworkService, OutboundFailure,
RequestFailure,
};
use sc_network_common::{
config::parse_addr,
protocol::ProtocolName,
service::{NetworkEventStream, NetworkNotification, NetworkPeers, NetworkRequest},
};
use sc_network_common::{config::parse_addr, protocol::ProtocolName};

use polkadot_node_network_protocol::{
peer_set::{PeerSet, PeerSetProtocolNames, ProtocolVersion},
Expand Down Expand Up @@ -193,8 +190,9 @@ impl Network for Arc<NetworkService<Block, Hash>> {
match pending_response
.send(Err(RequestFailure::Network(OutboundFailure::DialFailure)))
{
Err(_) =>
gum::debug!(target: LOG_TARGET, "Sending failed request response failed."),
Err(_) => {
gum::debug!(target: LOG_TARGET, "Sending failed request response failed.")
},
Ok(_) => {},
}
return
Expand Down
40 changes: 16 additions & 24 deletions node/network/protocol/src/peer_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,18 @@ impl PeerSet {
// Unfortunately, labels must be static strings, so we must manually cover them
// for all protocol versions here.
match self {
PeerSet::Validation => {
PeerSet::Validation =>
if version == ValidationVersion::V1.into() {
Some("validation/1")
} else {
None
}
},
PeerSet::Collation => {
},
PeerSet::Collation =>
if version == CollationVersion::V1.into() {
Some("collation/1")
} else {
None
}
},
},
}
}
}
Expand Down Expand Up @@ -246,7 +244,7 @@ impl PeerSetProtocolNames {
let mut names = HashMap::new();
for protocol in PeerSet::iter() {
match protocol {
PeerSet::Validation => {
PeerSet::Validation =>
for version in ValidationVersion::iter() {
Self::register_main_protocol(
&mut protocols,
Expand All @@ -256,9 +254,8 @@ impl PeerSetProtocolNames {
&genesis_hash,
fork_id,
);
}
},
PeerSet::Collation => {
},
PeerSet::Collation =>
for version in CollationVersion::iter() {
Self::register_main_protocol(
&mut protocols,
Expand All @@ -268,8 +265,7 @@ impl PeerSetProtocolNames {
&genesis_hash,
fork_id,
);
}
},
},
}
Self::register_legacy_protocol(&mut protocols, protocol);
}
Expand Down Expand Up @@ -491,7 +487,7 @@ mod tests {

for protocol in PeerSet::iter() {
match protocol {
PeerSet::Validation => {
PeerSet::Validation =>
for version in ValidationVersion::iter() {
assert_eq!(
protocol_names.get_name(protocol, version.into()),
Expand All @@ -502,9 +498,8 @@ mod tests {
version.into(),
),
);
}
},
PeerSet::Collation => {
},
PeerSet::Collation =>
for version in CollationVersion::iter() {
assert_eq!(
protocol_names.get_name(protocol, version.into()),
Expand All @@ -515,8 +510,7 @@ mod tests {
version.into(),
),
);
}
},
},
}
}
}
Expand All @@ -525,20 +519,18 @@ mod tests {
fn all_protocol_versions_have_labels() {
for protocol in PeerSet::iter() {
match protocol {
PeerSet::Validation => {
PeerSet::Validation =>
for version in ValidationVersion::iter() {
protocol
.get_protocol_label(version.into())
.expect("All validation protocol versions must have a label.");
}
},
PeerSet::Collation => {
},
PeerSet::Collation =>
for version in CollationVersion::iter() {
protocol
.get_protocol_label(version.into())
.expect("All collation protocol versions must have a label.");
}
},
},
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,7 @@ where

let authority_discovery_service = if auth_or_collator || overseer_enable_anyways {
use futures::StreamExt;
use sc_network::Event;
use sc_network_common::service::NetworkEventStream;
use sc_network::{Event, NetworkEventStream};

let authority_discovery_role = if role.is_authority() {
sc_authority_discovery::Role::PublishAndDiscover(keystore_container.keystore())
Expand Down
2 changes: 1 addition & 1 deletion node/service/src/overseer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use polkadot_primitives::runtime_api::ParachainHost;
use sc_authority_discovery::Service as AuthorityDiscoveryService;
use sc_client_api::AuxStore;
use sc_keystore::LocalKeystore;
use sc_network_common::service::NetworkStateInfo;
use sc_network::NetworkStateInfo;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus_babe::BabeApi;
Expand Down