mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 01:28:07 +00:00
RPCs for reserved peers (#4423)
* RPC forwarders for adding reserved peers * implement service side of reserved-peer RPCs * Clean up unnecessary format! invocation Co-Authored-By: Niklas Adolfsson <niklasadolfsson1@gmail.com> * add some tests for the new RPC methods * remove redundant `data` field Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
637d95e5ea
commit
da87c3c1e3
@@ -408,6 +408,17 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkWorker
|
||||
.map(|(id, info)| (id.clone(), info.clone()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Removes a `PeerId` from the list of reserved peers.
|
||||
pub fn remove_reserved_peer(&self, peer: PeerId) {
|
||||
self.service.remove_reserved_peer(peer);
|
||||
}
|
||||
|
||||
/// Adds a `PeerId` and its address as reserved. The string should encode the address
|
||||
/// and peer ID of the remote node.
|
||||
pub fn add_reserved_peer(&self, peer: String) -> Result<(), String> {
|
||||
self.service.add_reserved_peer(peer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkService<B, S, H> {
|
||||
@@ -553,7 +564,8 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkServic
|
||||
self.peerset.remove_reserved_peer(peer);
|
||||
}
|
||||
|
||||
/// Adds a `PeerId` and its address as reserved.
|
||||
/// Adds a `PeerId` and its address as reserved. The string should encode the address
|
||||
/// and peer ID of the remote node.
|
||||
pub fn add_reserved_peer(&self, peer: String) -> Result<(), String> {
|
||||
let (peer_id, addr) = parse_str_addr(&peer).map_err(|e| format!("{:?}", e))?;
|
||||
self.peerset.add_reserved_peer(peer_id.clone());
|
||||
|
||||
Reference in New Issue
Block a user