Check queue to determine major importing (#2763)
* simplify major sync detection * fix typos * fix merge * more realistic EthTester * add new synced state * remove Blocks synced state * move is_major_importing to rpc crate and check queue * add tests
This commit is contained in:
@@ -85,7 +85,7 @@ impl<R: URLHint> ContentFetcher<R> {
|
||||
// fallback to resolver
|
||||
if let Ok(content_id) = content_id.from_hex() {
|
||||
// if app_id is valid, but we are syncing always return true.
|
||||
if self.sync.is_major_syncing() {
|
||||
if self.sync.is_major_importing() {
|
||||
return true;
|
||||
}
|
||||
// else try to resolve the app_id
|
||||
@@ -99,7 +99,7 @@ impl<R: URLHint> ContentFetcher<R> {
|
||||
let mut cache = self.cache.lock();
|
||||
let content_id = path.app_id.clone();
|
||||
|
||||
if self.sync.is_major_syncing() {
|
||||
if self.sync.is_major_importing() {
|
||||
return Box::new(ContentHandler::error(
|
||||
StatusCode::ServiceUnavailable,
|
||||
"Sync In Progress",
|
||||
|
||||
@@ -95,11 +95,11 @@ static DAPPS_DOMAIN : &'static str = ".parity";
|
||||
/// Indicates sync status
|
||||
pub trait SyncStatus: Send + Sync {
|
||||
/// Returns true if there is a major sync happening.
|
||||
fn is_major_syncing(&self) -> bool;
|
||||
fn is_major_importing(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<F> SyncStatus for F where F: Fn() -> bool + Send + Sync {
|
||||
fn is_major_syncing(&self) -> bool { self() }
|
||||
fn is_major_importing(&self) -> bool { self() }
|
||||
}
|
||||
|
||||
/// Webapps HTTP+RPC server build.
|
||||
|
||||
Reference in New Issue
Block a user