mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 08:41:07 +00:00
Add an system_syncState RPC method (#7315)
* Add system_syncState RPC method * Update client/rpc-api/src/system/helpers.rs 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:
@@ -30,7 +30,7 @@ use sp_runtime::traits::{self, Header as HeaderT};
|
||||
use self::error::Result;
|
||||
|
||||
pub use sc_rpc_api::system::*;
|
||||
pub use self::helpers::{SystemInfo, Health, PeerInfo, NodeRole};
|
||||
pub use self::helpers::{SystemInfo, Health, PeerInfo, NodeRole, SyncState};
|
||||
pub use self::gen_client::Client as SystemClient;
|
||||
|
||||
macro_rules! bail_if_unsafe {
|
||||
@@ -66,7 +66,9 @@ pub enum Request<B: traits::Block> {
|
||||
/// Must return any potential parse error.
|
||||
NetworkRemoveReservedPeer(String, oneshot::Sender<Result<()>>),
|
||||
/// Must return the node role.
|
||||
NodeRoles(oneshot::Sender<Vec<NodeRole>>)
|
||||
NodeRoles(oneshot::Sender<Vec<NodeRole>>),
|
||||
/// Must return the state of the node syncing.
|
||||
SyncState(oneshot::Sender<SyncState<<B::Header as HeaderT>::Number>>),
|
||||
}
|
||||
|
||||
impl<B: traits::Block> System<B> {
|
||||
@@ -189,4 +191,10 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
|
||||
let _ = self.send_back.unbounded_send(Request::NodeRoles(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
}
|
||||
|
||||
fn system_sync_state(&self) -> Receiver<SyncState<<B::Header as HeaderT>::Number>> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::SyncState(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user