Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
bump last tick just before printing info and restore sync detection
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier committed Jul 18, 2017
1 parent 649552e commit 8b1548d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions parity/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl InformantData for FullNodeInformantData {
max_peers: status.current_max_peers(net_config.min_peers, net_config.max_peers),
}))
}
_ => (is_major_importing(None, queue_info.clone()), None),
_ => (is_major_importing(self.sync.as_ref().map(|s| s.status().state), queue_info.clone()), None),
};

Report {
Expand Down Expand Up @@ -254,8 +254,6 @@ impl<T: InformantData> Informant<T> {
return;
}

*self.last_tick.write() = Instant::now();

let (client_report, full_report) = {
let mut last_report = self.last_report.lock();
let full_report = self.target.report();
Expand Down Expand Up @@ -287,6 +285,8 @@ impl<T: InformantData> Informant<T> {
return;
}

*self.last_tick.write() = Instant::now();

let paint = |c: Style, t: String| match self.with_color && stdout_isatty() {
true => format!("{}", c.paint(t)),
false => t,
Expand Down
7 changes: 4 additions & 3 deletions rpc/src/v1/helpers/block_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ use ethsync::SyncState;

/// Check if client is during major sync or during block import.
pub fn is_major_importing(sync_state: Option<SyncState>, queue_info: BlockQueueInfo) -> bool {
let is_syncing_state = sync_state.map_or(false, |s|
s != SyncState::Idle && s != SyncState::NewBlocks
);
let is_syncing_state = sync_state.map_or(false, |s| match s {
SyncState::Idle | SyncState::NewBlocks | SyncState::WaitingPeers => false,
_ => true,
});
let is_verifying = queue_info.unverified_queue_size + queue_info.verified_queue_size > 3;
is_verifying || is_syncing_state
}
Expand Down

0 comments on commit 8b1548d

Please sign in to comment.