mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 06:08:00 +00:00
Add a JSON-RPC layer for reserved nodes (#8704)
* Add boilerplate for JSON-RPC layer for reserved nodes * Add more boilerplate for JSON-RPC layer for reserved nodes * Make JSON-RPC layer for reserved nodes async * Use more realistic data in reserver_peers tests * Make JSON-RPC layer for reserved nodes blocking * Apply tomaka's suggestion to reduce .into_iter() for an iter Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
committed by
GitHub
parent
de5d0b2312
commit
ef07c3be0d
@@ -1014,6 +1014,11 @@ impl<B: BlockT> Protocol<B> {
|
||||
self.peerset_handle.remove_reserved_peer(HARDCODED_PEERSETS_SYNC, peer.clone());
|
||||
}
|
||||
|
||||
/// Returns the list of reserved peers.
|
||||
pub fn reserved_peers(&self) -> impl Iterator<Item = &PeerId> {
|
||||
self.behaviour.reserved_peers(HARDCODED_PEERSETS_SYNC)
|
||||
}
|
||||
|
||||
/// 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());
|
||||
|
||||
@@ -555,6 +555,11 @@ impl Notifications {
|
||||
.map(|((id, _), _)| id)
|
||||
}
|
||||
|
||||
/// Returns the list of reserved peers.
|
||||
pub fn reserved_peers<'a>(&'a self, set_id: sc_peerset::SetId) -> impl Iterator<Item = &'a PeerId> + 'a {
|
||||
self.peerset.reserved_peers(set_id)
|
||||
}
|
||||
|
||||
/// Sends a notification to a peer.
|
||||
///
|
||||
/// Has no effect if the custom protocol is not open with the given peer.
|
||||
|
||||
@@ -619,6 +619,11 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
|
||||
pub fn add_reserved_peer(&self, peer: String) -> Result<(), String> {
|
||||
self.service.add_reserved_peer(peer)
|
||||
}
|
||||
|
||||
/// Returns the list of reserved peers.
|
||||
pub fn reserved_peers(&self) -> impl Iterator<Item = &PeerId> {
|
||||
self.network_service.behaviour().user_protocol().reserved_peers()
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT + 'static, H: ExHashT> NetworkService<B, H> {
|
||||
|
||||
Reference in New Issue
Block a user