client/network: Make NetworkService::set_priority_group async (#7352)

As done with `NetworkService::{add_to,remove_from}_priority_group`, make
`NetworkService::set_priority_group` async as well. This future-proofs
the API should we ever decide to use a bounded channel between
`NetworkService` and `NetworkWorker`.
This commit is contained in:
Max Inden
2020-10-22 11:15:39 +02:00
committed by GitHub
parent f450a6d74c
commit 0fcf9d6c60
5 changed files with 20 additions and 10 deletions
+4 -1
View File
@@ -973,7 +973,10 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
///
/// Returns an `Err` if one of the given addresses is invalid or contains an
/// invalid peer ID (which includes the local peer ID).
pub fn set_priority_group(&self, group_id: String, peers: HashSet<Multiaddr>) -> Result<(), String> {
//
// NOTE: even though this function is currently sync, it's marked as async for
// future-proofing, see https://github.com/paritytech/substrate/pull/7247#discussion_r502263451.
pub async fn set_priority_group(&self, group_id: String, peers: HashSet<Multiaddr>) -> Result<(), String> {
let peers = self.split_multiaddr_and_peer_id(peers)?;
let peer_ids = peers.iter().map(|(peer_id, _addr)| peer_id.clone()).collect();