mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 09:07:57 +00:00
Expose set_reserved_peers (#9960)
This commit is contained in:
@@ -1102,7 +1102,7 @@ impl<B: BlockT> Protocol<B> {
|
||||
|
||||
/// Removes a `PeerId` from the list of reserved peers for syncing purposes.
|
||||
pub fn remove_reserved_peer(&self, peer: PeerId) {
|
||||
self.peerset_handle.remove_reserved_peer(HARDCODED_PEERSETS_SYNC, peer.clone());
|
||||
self.peerset_handle.remove_reserved_peer(HARDCODED_PEERSETS_SYNC, peer);
|
||||
}
|
||||
|
||||
/// Returns the list of reserved peers.
|
||||
@@ -1112,12 +1112,26 @@ impl<B: BlockT> Protocol<B> {
|
||||
|
||||
/// Adds a `PeerId` to the list of reserved peers for syncing purposes.
|
||||
pub fn add_reserved_peer(&self, peer: PeerId) {
|
||||
self.peerset_handle.add_reserved_peer(HARDCODED_PEERSETS_SYNC, peer.clone());
|
||||
self.peerset_handle.add_reserved_peer(HARDCODED_PEERSETS_SYNC, peer);
|
||||
}
|
||||
|
||||
/// Sets the list of reserved peers for syncing purposes.
|
||||
pub fn set_reserved_peers(&self, peers: HashSet<PeerId>) {
|
||||
self.peerset_handle.set_reserved_peers(HARDCODED_PEERSETS_SYNC, peers.clone());
|
||||
self.peerset_handle.set_reserved_peers(HARDCODED_PEERSETS_SYNC, peers);
|
||||
}
|
||||
|
||||
/// Sets the list of reserved peers for the given protocol/peerset.
|
||||
pub fn set_reserved_peerset_peers(&self, protocol: Cow<'static, str>, peers: HashSet<PeerId>) {
|
||||
if let Some(index) = self.notification_protocols.iter().position(|p| *p == protocol) {
|
||||
self.peerset_handle
|
||||
.set_reserved_peers(sc_peerset::SetId::from(index + NUM_HARDCODED_PEERSETS), peers);
|
||||
} else {
|
||||
error!(
|
||||
target: "sub-libp2p",
|
||||
"set_reserved_peerset_peers with unknown protocol: {}",
|
||||
protocol
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes a `PeerId` from the list of reserved peers.
|
||||
|
||||
Reference in New Issue
Block a user