Don't check for updates while syncing.

This commit is contained in:
Gav Wood 2016-12-16 10:14:44 +01:00
parent ba60e046be
commit 35b18485d4
No known key found for this signature in database
GPG Key ID: C49C1ACA1CC9B252
4 changed files with 12 additions and 5 deletions

1
Cargo.lock generated
View File

@ -1393,6 +1393,7 @@ dependencies = [
"ethcore-ipc 1.5.0", "ethcore-ipc 1.5.0",
"ethcore-ipc-codegen 1.5.0", "ethcore-ipc-codegen 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"ethsync 1.5.0",
"ipc-common-types 1.5.0", "ipc-common-types 1.5.0",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-hash-fetch 1.5.0", "parity-hash-fetch 1.5.0",

View File

@ -13,6 +13,7 @@ ethcore-ipc-codegen = { path = "../ipc/codegen" }
log = "0.3" log = "0.3"
ethabi = "0.2.2" ethabi = "0.2.2"
ethcore = { path = "../ethcore" } ethcore = { path = "../ethcore" }
ethsync = { path = "../sync" }
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
parity-hash-fetch = { path = "../hash-fetch" } parity-hash-fetch = { path = "../hash-fetch" }
ipc-common-types = { path = "../ipc-common-types" } ipc-common-types = { path = "../ipc-common-types" }

View File

@ -22,6 +22,7 @@ extern crate ipc_common_types;
extern crate parity_hash_fetch as hash_fetch; extern crate parity_hash_fetch as hash_fetch;
extern crate ethcore; extern crate ethcore;
extern crate ethabi; extern crate ethabi;
extern crate ethsync;
extern crate ethcore_ipc as ipc; extern crate ethcore_ipc as ipc;
mod updater; mod updater;

View File

@ -21,11 +21,13 @@ use std::path::{PathBuf};
use util::misc::platform; use util::misc::platform;
use ipc_common_types::{VersionInfo, ReleaseTrack}; use ipc_common_types::{VersionInfo, ReleaseTrack};
use util::{Address, H160, H256, FixedHash, Mutex, Bytes}; use util::{Address, H160, H256, FixedHash, Mutex, Bytes};
use ethsync::{SyncProvider};
use ethcore::client::{BlockId, BlockChainClient, ChainNotify}; use ethcore::client::{BlockId, BlockChainClient, ChainNotify};
use hash_fetch::{self as fetch, HashFetch}; use hash_fetch::{self as fetch, HashFetch};
use operations::Operations; use operations::Operations;
use service::{Service}; use service::{Service};
use types::all::{ReleaseInfo, OperationsInfo, CapState}; use types::all::{ReleaseInfo, OperationsInfo, CapState};
use ethcore_rpc::is_major_importing;
/// Filter for releases. /// Filter for releases.
#[derive(Debug, Eq, PartialEq, Clone)] #[derive(Debug, Eq, PartialEq, Clone)]
@ -82,6 +84,7 @@ pub struct Updater {
update_policy: UpdatePolicy, update_policy: UpdatePolicy,
weak_self: Mutex<Weak<Updater>>, weak_self: Mutex<Weak<Updater>>,
client: Weak<BlockChainClient>, client: Weak<BlockChainClient>,
sync: Weak<SyncProvider>,
fetcher: Mutex<Option<fetch::Client>>, fetcher: Mutex<Option<fetch::Client>>,
operations: Mutex<Option<Operations>>, operations: Mutex<Option<Operations>>,
exit_handler: Mutex<Option<Box<Fn() + 'static + Send>>>, exit_handler: Mutex<Option<Box<Fn() + 'static + Send>>>,
@ -96,11 +99,12 @@ pub struct Updater {
const CLIENT_ID: &'static str = "parity"; const CLIENT_ID: &'static str = "parity";
impl Updater { impl Updater {
pub fn new(client: Weak<BlockChainClient>, update_policy: UpdatePolicy) -> Arc<Self> { pub fn new(client: Weak<BlockChainClient>, sync: Arc<SyncProvider>, update_policy: UpdatePolicy) -> Arc<Self> {
let r = Arc::new(Updater { let r = Arc::new(Updater {
update_policy: update_policy, update_policy: update_policy,
weak_self: Mutex::new(Default::default()), weak_self: Mutex::new(Default::default()),
client: client.clone(), client: client.clone(),
sync: sync.clone(),
fetcher: Mutex::new(None), fetcher: Mutex::new(None),
operations: Mutex::new(None), operations: Mutex::new(None),
exit_handler: Mutex::new(None), exit_handler: Mutex::new(None),
@ -290,10 +294,10 @@ impl Updater {
impl ChainNotify for Updater { impl ChainNotify for Updater {
fn new_blocks(&self, _imported: Vec<H256>, _invalid: Vec<H256>, _enacted: Vec<H256>, _retracted: Vec<H256>, _sealed: Vec<H256>, _proposed: Vec<Bytes>, _duration: u64) { fn new_blocks(&self, _imported: Vec<H256>, _invalid: Vec<H256>, _enacted: Vec<H256>, _retracted: Vec<H256>, _sealed: Vec<H256>, _proposed: Vec<Bytes>, _duration: u64) {
// TODO: something like this match (self.client.upgrade(), self.sync.upgrade()) {
// if !self.client.upgrade().map_or(true, |c| c.is_major_syncing()) { (Some(c), Some(s)) if is_major_importing(s.status().state, c.queue_info()) => self.poll(),
self.poll(); _ => {},
// } }
} }
} }