refactor the state_sync to handle the long fork (#1902)

* split horizon into two explicit values for cut through and txhashset request

* let node which has 2-7 days of history be able to handle forks larger than 2 days

* add test simulate_long_fork

* add pause/resume feature on p2p for tests

* refactor the state_sync

* ignore the test case simulate_long_fork for normal Travis-CI

* refactor function check_txhashset_needed to be shared with body_sync

* fix: state TxHashsetDone should allow header sync
This commit is contained in:
Gary Yu
2018-11-10 11:27:52 +08:00
committed by GitHub
parent 408fcc386e
commit 9af9ca9518
17 changed files with 788 additions and 144 deletions
+6 -3
View File
@@ -125,7 +125,7 @@ impl TUIStatusListener for TUIStatusView {
let fin = Utc::now().timestamp_nanos();
let dur_ms = (fin - start) as f64 * NANO_TO_MILLIS;
format!("Downloading {}(MB) chain state for fast sync: {}% at {:.1?}(kB/s), step 2/4",
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 },
@@ -135,7 +135,7 @@ impl TUIStatusListener for TUIStatusView {
let fin = Utc::now().timestamp_millis();
let dur_secs = (fin - start) / 1000;
format!("Downloading chain state for fast sync. Waiting remote peer to start: {}s, step 2/4",
format!("Downloading chain state for state sync. Waiting remote peer to start: {}s, step 2/4",
dur_secs,
)
}
@@ -164,7 +164,10 @@ impl TUIStatusListener for TUIStatusView {
format!("Validating chain state: {}%, step 3/4", percent)
}
SyncStatus::TxHashsetSave => {
"Finalizing chain state for fast sync, step 3/4".to_string()
"Finalizing chain state for state sync, step 3/4".to_string()
}
SyncStatus::TxHashsetDone => {
"Finalized chain state for state sync, step 3/4".to_string()
}
SyncStatus::BodySync {
current_height,