Make NetworkService::add_reserved_peer() accept MultiaddrWithPeerId (#12102)

* Make `add_reserved_peer()` accept `MultiaddrWithPeerId`

* minor: cargo fmt

* minor: error to string conversion

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Dmitry Markin
2022-08-29 14:54:57 +03:00
committed by GitHub
parent 674e73caf0
commit 224562729d
9 changed files with 49 additions and 34 deletions
@@ -19,6 +19,7 @@
// If you read this, you are very thorough, congratulations.
use crate::{
config::MultiaddrWithPeerId,
protocol::event::Event,
request_responses::{IfDisconnected, RequestFailure},
sync::{warp::WarpSyncProgress, StateDownloadProgress, SyncState},
@@ -179,12 +180,11 @@ pub trait NetworkPeers {
/// purposes.
fn deny_unreserved_peers(&self);
/// Adds a `PeerId` and its address as reserved. The string should encode the address
/// and peer ID of the remote node.
/// Adds a `PeerId` and its `Multiaddr` as reserved.
///
/// Returns an `Err` if the given string is not a valid multiaddress
/// or contains an invalid peer ID (which includes the local peer ID).
fn add_reserved_peer(&self, peer: String) -> Result<(), String>;
fn add_reserved_peer(&self, peer: MultiaddrWithPeerId) -> Result<(), String>;
/// Removes a `PeerId` from the list of reserved peers.
fn remove_reserved_peer(&self, peer_id: PeerId);
@@ -285,7 +285,7 @@ where
T::deny_unreserved_peers(self)
}
fn add_reserved_peer(&self, peer: String) -> Result<(), String> {
fn add_reserved_peer(&self, peer: MultiaddrWithPeerId) -> Result<(), String> {
T::add_reserved_peer(self, peer)
}