Report the average network bandwidth (#1551)

* Report the average network bandwidth

* Fix concerns
This commit is contained in:
Pierre Krieger authored and Gav Wood committed 2019-01-25 10:34:34 +00:00
1 parent aeb6aa8b48
commit a1586df41b
7 files changed
+342 -9

No files matched your search

+12
View File
@@ -173,6 +173,18 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> Service<B, S,
Ok(service)
}
/// Returns the downloaded bytes per second averaged over the past few seconds.
#[inline]
pub fn average_download_per_sec(&self) -> u64 {
self.network.lock().average_download_per_sec()
}
/// Returns the uploaded bytes per second averaged over the past few seconds.
#[inline]
pub fn average_upload_per_sec(&self) -> u64 {
self.network.lock().average_upload_per_sec()
}
/// Called when a new block is imported by the client.
pub fn on_block_imported(&self, hash: B::Hash, header: &B::Header) {
self.handler.on_block_imported(&mut NetSyncIo::new(&self.network, self.protocol_id), hash, header)