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
+3 -4
View File
@@ -261,6 +261,8 @@ pub enum SyncStatus {
},
/// Finalizing the new state
TxHashsetSave,
/// State sync finalized
TxHashsetDone,
/// Downloading blocks
BodySync {
current_height: u64,
@@ -383,9 +385,6 @@ impl chain::TxHashsetWriteStatus for SyncState {
}
fn on_done(&self) {
self.update(SyncStatus::BodySync {
current_height: 0,
highest_height: 0,
});
self.update(SyncStatus::TxHashsetDone);
}
}