mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
Add alternative RPC methods to system_networkState (#5643)
* Add alternatives to system_networkState * Fix tests * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
@@ -41,6 +41,11 @@ pub struct System<B: traits::Block> {
|
||||
pub enum Request<B: traits::Block> {
|
||||
/// Must return the health of the network.
|
||||
Health(oneshot::Sender<Health>),
|
||||
/// Must return the base58-encoded local `PeerId`.
|
||||
LocalPeerId(oneshot::Sender<String>),
|
||||
/// Must return the string representation of the addresses we listen on, including the
|
||||
/// trailing `/p2p/`.
|
||||
LocalListenAddresses(oneshot::Sender<Vec<String>>),
|
||||
/// Must return information about the peers we are connected to.
|
||||
Peers(oneshot::Sender<Vec<PeerInfo<B::Hash, <B::Header as HeaderT>::Number>>>),
|
||||
/// Must return the state of the network.
|
||||
@@ -96,6 +101,18 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
|
||||
Receiver(Compat::new(rx))
|
||||
}
|
||||
|
||||
fn system_local_peer_id(&self) -> Receiver<String> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::LocalPeerId(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
}
|
||||
|
||||
fn system_local_listen_addresses(&self) -> Receiver<Vec<String>> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::LocalListenAddresses(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
}
|
||||
|
||||
fn system_peers(&self) -> Receiver<Vec<PeerInfo<B::Hash, <B::Header as HeaderT>::Number>>> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::Peers(tx));
|
||||
|
||||
Reference in New Issue
Block a user