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

Check if synced when using eth_getWork (#9193) #9210

Merged
merged 6 commits into from
Jul 31, 2018
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions rpc/src/v1/impls/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use ethcore::header::{BlockNumber as EthBlockNumber};
use ethcore::log_entry::LogEntry;
use ethcore::miner::{self, MinerService};
use ethcore::snapshot::SnapshotService;
use ethcore::snapshot::RestorationStatus;
use ethcore::encoded;
use sync::{SyncProvider};
use miner::external::ExternalMinerService;
Expand Down Expand Up @@ -479,8 +480,6 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<
}

fn syncing(&self) -> Result<SyncStatus> {
use ethcore::snapshot::RestorationStatus;

let status = self.sync.status();
let client = &self.client;
let snapshot_status = self.snapshot.status();
Expand Down Expand Up @@ -744,9 +743,14 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> Eth for EthClient<

// check if we're still syncing and return empty strings in that case
{
//TODO: check if initial sync is complete here
//let sync = self.sync;
if /*sync.status().state != SyncState::Idle ||*/ self.client.queue_info().total_queue_size() > MAX_QUEUE_SIZE_TO_MINE_ON {
let status = self.sync.status();
let client = &self.client;
let warping = match self.snapshot.status() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to check for this, I think is_major_importing should already return true if we're warping (although would be nice if you could test this).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I tested this and it appears you were correct, so I've removed the extra check for warping.

RestorationStatus::Ongoing { .. } => true,
_ => false,
};

if warping || is_major_importing(Some(status.state), client.queue_info()) || self.client.queue_info().total_queue_size() > MAX_QUEUE_SIZE_TO_MINE_ON {
trace!(target: "miner", "Syncing. Cannot give any work.");
return Err(errors::no_work());
}
Expand Down