mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +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:
@@ -80,7 +80,7 @@ pub use sc_tracing::TracingReceiver;
|
||||
pub use task_manager::SpawnTaskHandle;
|
||||
pub use task_manager::TaskManager;
|
||||
pub use sp_consensus::import_queue::ImportQueue;
|
||||
use sc_client_api::BlockchainEvents;
|
||||
use sc_client_api::{blockchain::HeaderBackend, BlockchainEvents};
|
||||
|
||||
const DEFAULT_PROTOCOL_ID: &str = "sup";
|
||||
|
||||
@@ -199,7 +199,7 @@ pub struct PartialComponents<Client, Backend, SelectChain, ImportQueue, Transact
|
||||
/// The `status_sink` contain a list of senders to send a periodic network status to.
|
||||
async fn build_network_future<
|
||||
B: BlockT,
|
||||
C: BlockchainEvents<B>,
|
||||
C: BlockchainEvents<B> + HeaderBackend<B>,
|
||||
H: sc_network::ExHashT
|
||||
> (
|
||||
role: Role,
|
||||
@@ -212,6 +212,9 @@ async fn build_network_future<
|
||||
) {
|
||||
let mut imported_blocks_stream = client.import_notification_stream().fuse();
|
||||
|
||||
// Current best block at initialization, to report to the RPC layer.
|
||||
let starting_block = client.info().best_number;
|
||||
|
||||
// Stream of finalized blocks reported by the client.
|
||||
let mut finality_notification_stream = {
|
||||
let mut finality_notification_stream = client.finality_notification_stream().fuse();
|
||||
@@ -323,6 +326,15 @@ async fn build_network_future<
|
||||
|
||||
let _ = sender.send(vec![node_role]);
|
||||
}
|
||||
sc_rpc::system::Request::SyncState(sender) => {
|
||||
use sc_rpc::system::SyncState;
|
||||
|
||||
let _ = sender.send(SyncState {
|
||||
starting_block: starting_block,
|
||||
current_block: client.info().best_number,
|
||||
highest_block: network.best_seen_block(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user