Unify major syncing detection (#2699)

* simplify major sync detection

* fix typos

* fix merge

* more realistic EthTester

* add new synced state
This commit is contained in:
keorn
2016-10-19 17:35:39 +01:00
committed by Gav Wood
parent 319cfb278c
commit aa52b04e31
6 changed files with 44 additions and 42 deletions

View File

@@ -204,7 +204,13 @@ pub struct SyncStatus {
impl SyncStatus {
/// Indicates if initial sync is still in progress.
pub fn is_major_syncing(&self) -> bool {
self.state != SyncState::Idle && self.state != SyncState::NewBlocks
let is_synced_state = match self.state {
SyncState::Idle | SyncState::NewBlocks | SyncState::Blocks => true,
_ => false,
};
let is_current_block = self.highest_block_number.unwrap_or(self.start_block_number) < self.last_imported_block_number.unwrap_or(0) + BlockNumber::from(4u64);
// If not synced then is major syncing.
!(is_synced_state && is_current_block)
}
/// Indicates if snapshot download is in progress