Do not sync when configured with no seeding
This commit is contained in:
@@ -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
@@ -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
@@ -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,
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user