Do not sync when configured with no seeding

This commit is contained in:
Ignotus Peverell
2017-10-17 13:51:02 +00:00
parent 7dbd1ef962
commit 28ac46c563
4 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -239,7 +239,7 @@ impl NetToChainAdapter {
}
pub fn syncing(&self) -> bool {
self.syncer.borrow().syncing()
self.syncer.is_initialized() && self.syncer.borrow().syncing()
}
/// Prepare options for the chain pipeline
+4 -2
View File
@@ -129,8 +129,10 @@ impl Server {
}
}
let sync = sync::Syncer::new(shared_chain.clone(), p2p_server.clone());
net_adapter.start_sync(sync);
if config.seeding_type != Seeding::None {
let sync = sync::Syncer::new(shared_chain.clone(), p2p_server.clone());
net_adapter.start_sync(sync);
}
evt_handle.spawn(p2p_server.start(evt_handle.clone()).map_err(|_| ()));
+1 -1
View File
@@ -60,7 +60,7 @@ impl From<api::Error> for Error {
}
/// Type of seeding the server will use to find other peers on the network.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum Seeding {
/// No seeding, mostly for tests that programmatically connect
None,
+5
View File
@@ -73,6 +73,11 @@ impl<T> OneTime<T> {
*inner_mut = Some(value);
}
pub fn is_initialized(&self) -> bool {
let inner = self.inner.borrow();
inner.is_some()
}
/// Borrows the OneTime, should only be called after initialization.
pub fn borrow(&self) -> Ref<T> {
Ref::map(self.inner.borrow(), |o| o.as_ref().unwrap())