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
@@ -256,7 +256,7 @@ impl IntoProtocolsHandler for NotifsHandlerProto {
Protocol { config, in_upgrade, state: State::Closed { pending_opening: false } }
})
.collect(),
peer_id: peer_id.clone(),
peer_id: *peer_id,
endpoint: connected_point.clone(),
when_connection_open: Instant::now(),
events_queue: VecDeque::with_capacity(16),
@@ -463,7 +463,7 @@ impl NotifsHandlerProto {
/// is always the same whether we open a substream ourselves or respond to handshake from
/// the remote.
pub fn new(list: impl Into<Vec<ProtocolConfig>>) -> Self {
NotifsHandlerProto { protocols: list.into() }
Self { protocols: list.into() }
}
}
@@ -552,7 +552,7 @@ impl ProtocolsHandler for NotifsHandler {
let (sync_tx, sync_rx) = mpsc::channel(SYNC_NOTIFICATIONS_BUFFER_SIZE);
let notifications_sink = NotificationsSink {
inner: Arc::new(NotificationsSinkInner {
peer_id: self.peer_id.clone(),
peer_id: self.peer_id,
async_channel: FuturesMutex::new(async_tx),
sync_channel: Mutex::new(sync_tx),
}),