Clean up sc-network (#9761)

* Clean up sc-network

- Avoid using clone() for the Copy type `PeerId`.
- Use `find_map` for `filter_map` and `next`.
- Use `Self`.

* More on Copy types

* Cargo +nightly fmt --all

* More ..

* fmt

* Revert vec![default_notif_handshake_message]
This commit is contained in:
Liu-Cheng Xu
2021-09-14 02:11:29 +08:00
committed by GitHub
parent 0472a43855
commit 2562f8c65e
37 changed files with 475 additions and 526 deletions
@@ -142,7 +142,7 @@ impl OutChannels {
let metrics =
if let Some(registry) = registry { Some(Metrics::register(registry)?) } else { None };
Ok(OutChannels { event_streams: Vec::new(), metrics: Arc::new(metrics) })
Ok(Self { event_streams: Vec::new(), metrics: Arc::new(metrics) })
}
/// Adds a new [`Sender`] to the collection.
@@ -356,15 +356,13 @@ fn lots_of_incoming_peers_works() {
..config::NetworkConfiguration::new_local()
});
let main_node_peer_id = main_node.local_peer_id().clone();
let main_node_peer_id = *main_node.local_peer_id();
// We spawn background tasks and push them in this `Vec`. They will all be waited upon before
// this test ends.
let mut background_tasks_to_wait = Vec::new();
for _ in 0..32 {
let main_node_peer_id = main_node_peer_id.clone();
let (_dialing_node, event_stream) = build_test_full_node(config::NetworkConfiguration {
listen_addresses: vec![],
extra_sets: vec![config::NonDefaultSetConfig {
@@ -374,7 +372,7 @@ fn lots_of_incoming_peers_works() {
set_config: config::SetConfig {
reserved_nodes: vec![config::MultiaddrWithPeerId {
multiaddr: listen_addr.clone(),
peer_id: main_node_peer_id.clone(),
peer_id: main_node_peer_id,
}],
..Default::default()
},