From 95ef1e9c7a6419aa541c0d5b392454b2295b25fa Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Thu, 5 Jan 2023 15:56:19 +0800 Subject: [PATCH] Optional download (#183) --- tool/state-processor/src/processor.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tool/state-processor/src/processor.rs b/tool/state-processor/src/processor.rs index db3beaa4f..b5e4c3f23 100644 --- a/tool/state-processor/src/processor.rs +++ b/tool/state-processor/src/processor.rs @@ -4,6 +4,7 @@ use std::{ io::{Read, Write}, marker::PhantomData, mem, + path::Path, sync::RwLock, }; // darwinia @@ -35,13 +36,18 @@ where { pub fn new() -> Result { build_spec(S::NAME)?; - download_specs(S::NAME)?; let mut shell_chain_spec = from_file::(&format!("data/{}-shell.json", S::NAME))?; + let solo_path = format!("data/{}-solo.json", S::NAME); + let para_path = format!("data/{}-para.json", S::NAME); + + if !Path::new(&solo_path).is_file() || !Path::new(¶_path).is_file() { + download_specs(S::NAME)?; + } Ok(Self { - solo_state: State::from_file(&format!("data/{}-solo.json", S::NAME))?, - para_state: State::from_file(&format!("data/{}-para.json", S::NAME))?, + solo_state: State::from_file(&solo_path)?, + para_state: State::from_file(¶_path)?, shell_state: State { map: mem::take(&mut shell_chain_spec.genesis.raw.top), _runtime: Default::default(),