Refactor SyncState (#3297)

* Refactor SyncState

Method sync_error() retrun type was simplified.
update_txhashset_download() was  made type safe, which eliminates a runtime enum variant's  check, added an atomic status update
This commit is contained in:
hashmap
2020-04-20 12:30:04 +02:00
committed by GitHub
parent e64e90623b
commit d8c6eef485
7 changed files with 130 additions and 106 deletions
+4 -9
View File
@@ -79,16 +79,11 @@ fn sync_status_to_api(sync_status: SyncStatus) -> (String, Option<serde_json::Va
"header_sync".to_string(),
Some(json!({ "current_height": current_height, "highest_height": highest_height })),
),
SyncStatus::TxHashsetDownload {
start_time: _,
prev_update_time: _,
update_time: _,
prev_downloaded_size: _,
downloaded_size,
total_size,
} => (
SyncStatus::TxHashsetDownload(stats) => (
"txhashset_download".to_string(),
Some(json!({ "downloaded_size": downloaded_size, "total_size": total_size })),
Some(
json!({ "downloaded_size": stats.downloaded_size, "total_size": stats.total_size }),
),
),
SyncStatus::TxHashsetRangeProofsValidation {
rproofs,