Don't check for updates while syncing.
This commit is contained in:
parent
ba60e046be
commit
35b18485d4
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1393,6 +1393,7 @@ dependencies = [
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-ipc-codegen 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"ethsync 1.5.0",
|
||||
"ipc-common-types 1.5.0",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-hash-fetch 1.5.0",
|
||||
|
@ -13,6 +13,7 @@ ethcore-ipc-codegen = { path = "../ipc/codegen" }
|
||||
log = "0.3"
|
||||
ethabi = "0.2.2"
|
||||
ethcore = { path = "../ethcore" }
|
||||
ethsync = { path = "../sync" }
|
||||
ethcore-util = { path = "../util" }
|
||||
parity-hash-fetch = { path = "../hash-fetch" }
|
||||
ipc-common-types = { path = "../ipc-common-types" }
|
||||
|
@ -22,6 +22,7 @@ extern crate ipc_common_types;
|
||||
extern crate parity_hash_fetch as hash_fetch;
|
||||
extern crate ethcore;
|
||||
extern crate ethabi;
|
||||
extern crate ethsync;
|
||||
extern crate ethcore_ipc as ipc;
|
||||
|
||||
mod updater;
|
||||
|
@ -21,11 +21,13 @@ use std::path::{PathBuf};
|
||||
use util::misc::platform;
|
||||
use ipc_common_types::{VersionInfo, ReleaseTrack};
|
||||
use util::{Address, H160, H256, FixedHash, Mutex, Bytes};
|
||||
use ethsync::{SyncProvider};
|
||||
use ethcore::client::{BlockId, BlockChainClient, ChainNotify};
|
||||
use hash_fetch::{self as fetch, HashFetch};
|
||||
use operations::Operations;
|
||||
use service::{Service};
|
||||
use types::all::{ReleaseInfo, OperationsInfo, CapState};
|
||||
use ethcore_rpc::is_major_importing;
|
||||
|
||||
/// Filter for releases.
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
@ -82,6 +84,7 @@ pub struct Updater {
|
||||
update_policy: UpdatePolicy,
|
||||
weak_self: Mutex<Weak<Updater>>,
|
||||
client: Weak<BlockChainClient>,
|
||||
sync: Weak<SyncProvider>,
|
||||
fetcher: Mutex<Option<fetch::Client>>,
|
||||
operations: Mutex<Option<Operations>>,
|
||||
exit_handler: Mutex<Option<Box<Fn() + 'static + Send>>>,
|
||||
@ -96,11 +99,12 @@ pub struct Updater {
|
||||
const CLIENT_ID: &'static str = "parity";
|
||||
|
||||
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 {
|
||||
update_policy: update_policy,
|
||||
weak_self: Mutex::new(Default::default()),
|
||||
client: client.clone(),
|
||||
sync: sync.clone(),
|
||||
fetcher: Mutex::new(None),
|
||||
operations: Mutex::new(None),
|
||||
exit_handler: Mutex::new(None),
|
||||
@ -290,10 +294,10 @@ impl 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) {
|
||||
// TODO: something like this
|
||||
// if !self.client.upgrade().map_or(true, |c| c.is_major_syncing()) {
|
||||
self.poll();
|
||||
// }
|
||||
match (self.client.upgrade(), self.sync.upgrade()) {
|
||||
(Some(c), Some(s)) if is_major_importing(s.status().state, c.queue_info()) => self.poll(),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user