mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Get the correct number of connected peers in SyncState (#13700)
`Protocol` is not a reliable source for the information of connected peers because it doesn't have real-time information of the actual connectivity state because it's not resposible for accepting/rejecting connections and gets that information with delay from `SyncinEngine`.
This commit is contained in:
@@ -711,7 +711,9 @@ where
|
||||
ToServiceCommand::NewBestBlockImported(hash, number) =>
|
||||
self.new_best_block_imported(hash, number),
|
||||
ToServiceCommand::Status(tx) => {
|
||||
let _ = tx.send(self.chain_sync.status());
|
||||
let mut status = self.chain_sync.status();
|
||||
status.num_connected_peers = self.peers.len() as u32;
|
||||
let _ = tx.send(status);
|
||||
},
|
||||
ToServiceCommand::NumActivePeers(tx) => {
|
||||
let _ = tx.send(self.chain_sync.num_active_peers());
|
||||
|
||||
@@ -523,6 +523,7 @@ where
|
||||
state: sync_state,
|
||||
best_seen_block,
|
||||
num_peers: self.peers.len() as u32,
|
||||
num_connected_peers: 0u32,
|
||||
queued_blocks: self.queue_blocks.len() as u32,
|
||||
state_sync: self.state_sync.as_ref().map(|s| s.progress()),
|
||||
warp_sync: warp_sync_progress,
|
||||
|
||||
Reference in New Issue
Block a user