fix: no need switching to HeaderSync in FastSync states (#1622)

* fix: no need switching to HeaderSync in FastSync states
This commit is contained in:
Gary Yu 2018-10-02 12:09:49 +08:00 committed by GitHub
parent 6d67cbdecb
commit d7fbeb2c62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -199,8 +199,8 @@ fn do_header_sync(
) { ) {
let status = sync_state.status(); let status = sync_state.status();
let update_sync_state = match status { let enable_header_sync = match status {
SyncStatus::TxHashsetDownload => false, SyncStatus::BodySync { .. } | SyncStatus::HeaderSync { .. } => true,
SyncStatus::NoSync | SyncStatus::Initial => { SyncStatus::NoSync | SyncStatus::Initial => {
// Reset sync_head to header_head on transition to HeaderSync, // Reset sync_head to header_head on transition to HeaderSync,
// but ONLY on initial transition to HeaderSync state. // but ONLY on initial transition to HeaderSync state.
@ -217,17 +217,17 @@ fn do_header_sync(
history_locators.clear(); history_locators.clear();
true true
} }
_ => true, _ => false,
}; };
if update_sync_state { if enable_header_sync {
sync_state.update(SyncStatus::HeaderSync { sync_state.update(SyncStatus::HeaderSync {
current_height: header_head.height, current_height: header_head.height,
highest_height: si.highest_height, highest_height: si.highest_height,
}); });
}
header_sync(peers, chain, history_locators); header_sync(peers, chain, history_locators);
}
} }
fn do_fast_sync( fn do_fast_sync(