mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Display the current download rate rather than the average when syncing the chain (#2633)
* When syncing the chain, calculate the displayed download speed using the current rate from the most recent iteration, rather than the average download speed from the entire syncing process. * Replace the explicitly ignored variables in the pattern with an implicit ignore
This commit is contained in:
parent
d0ade29fc2
commit
4c9984cf11
4 changed files with 19 additions and 3 deletions
|
@ -326,10 +326,17 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
|||
total_size: u64,
|
||||
) -> bool {
|
||||
match self.sync_state.status() {
|
||||
SyncStatus::TxHashsetDownload { .. } => {
|
||||
SyncStatus::TxHashsetDownload {
|
||||
update_time: old_update_time,
|
||||
downloaded_size: old_downloaded_size,
|
||||
..
|
||||
} => {
|
||||
self.sync_state
|
||||
.update_txhashset_download(SyncStatus::TxHashsetDownload {
|
||||
start_time,
|
||||
prev_update_time: old_update_time,
|
||||
update_time: Utc::now(),
|
||||
prev_downloaded_size: old_downloaded_size,
|
||||
downloaded_size,
|
||||
total_size,
|
||||
})
|
||||
|
|
|
@ -262,6 +262,9 @@ pub enum SyncStatus {
|
|||
/// Downloading the various txhashsets
|
||||
TxHashsetDownload {
|
||||
start_time: DateTime<Utc>,
|
||||
prev_update_time: DateTime<Utc>,
|
||||
update_time: DateTime<Utc>,
|
||||
prev_downloaded_size: u64,
|
||||
downloaded_size: u64,
|
||||
total_size: u64,
|
||||
},
|
||||
|
|
|
@ -147,6 +147,9 @@ impl StateSync {
|
|||
|
||||
self.sync_state.update(SyncStatus::TxHashsetDownload {
|
||||
start_time: Utc::now(),
|
||||
prev_update_time: Utc::now(),
|
||||
update_time: Utc::now(),
|
||||
prev_downloaded_size: 0,
|
||||
downloaded_size: 0,
|
||||
total_size: 0,
|
||||
});
|
||||
|
|
|
@ -128,6 +128,9 @@ impl TUIStatusListener for TUIStatusView {
|
|||
}
|
||||
SyncStatus::TxHashsetDownload {
|
||||
start_time,
|
||||
prev_update_time,
|
||||
update_time: _,
|
||||
prev_downloaded_size,
|
||||
downloaded_size,
|
||||
total_size,
|
||||
} => {
|
||||
|
@ -137,14 +140,14 @@ impl TUIStatusListener for TUIStatusView {
|
|||
} else {
|
||||
0
|
||||
};
|
||||
let start = start_time.timestamp_nanos();
|
||||
let start = prev_update_time.timestamp_nanos();
|
||||
let fin = Utc::now().timestamp_nanos();
|
||||
let dur_ms = (fin - start) as f64 * NANO_TO_MILLIS;
|
||||
|
||||
format!("Downloading {}(MB) chain state for state sync: {}% at {:.1?}(kB/s), step 2/4",
|
||||
total_size / 1_000_000,
|
||||
percent,
|
||||
if dur_ms > 1.0f64 { downloaded_size as f64 / dur_ms as f64 } else { 0f64 },
|
||||
if dur_ms > 1.0f64 { (downloaded_size - prev_downloaded_size) as f64 / dur_ms as f64 } else { 0f64 },
|
||||
)
|
||||
} else {
|
||||
let start = start_time.timestamp_millis();
|
||||
|
|
Loading…
Reference in a new issue