From 319a01b34f601b24ee94c1d33092d8875675c0de Mon Sep 17 00:00:00 2001 From: Giuseppe Bertone Date: Tue, 18 Jul 2017 15:38:38 +0200 Subject: [PATCH] User_defaults now contains serialization for is_first_launch parameter; (#6068) Solved the "TraceDB resync required" issue when trying to use "--tracing on" option just after a DB kill operation; --- parity/blockchain.rs | 4 +++- parity/run.rs | 1 + parity/user_defaults.rs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/parity/blockchain.rs b/parity/blockchain.rs index fae9a3bfc..a70272931 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -531,10 +531,12 @@ pub fn kill_db(cmd: KillBlockchain) -> Result<(), String> { let genesis_hash = spec.genesis_header().hash(); let db_dirs = cmd.dirs.database(genesis_hash, None, spec.data_dir); let user_defaults_path = db_dirs.user_defaults_path(); - let user_defaults = UserDefaults::load(&user_defaults_path)?; + let mut user_defaults = UserDefaults::load(&user_defaults_path)?; let algorithm = cmd.pruning.to_algorithm(&user_defaults); let dir = db_dirs.db_path(algorithm); fs::remove_dir_all(&dir).map_err(|e| format!("Error removing database: {:?}", e))?; + user_defaults.is_first_launch = true; + user_defaults.save(&user_defaults_path)?; info!("Database deleted."); Ok(()) } diff --git a/parity/run.rs b/parity/run.rs index 15e09d74a..6f0b444a0 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -754,6 +754,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc) -> R service.register_io_handler(informant.clone()).map_err(|_| "Unable to register informant handler".to_owned())?; // save user defaults + user_defaults.is_first_launch = false; user_defaults.pruning = algorithm; user_defaults.tracing = tracing; user_defaults.fat_db = fat_db; diff --git a/parity/user_defaults.rs b/parity/user_defaults.rs index 12bb9937f..703b3bf16 100644 --- a/parity/user_defaults.rs +++ b/parity/user_defaults.rs @@ -41,6 +41,7 @@ impl Serialize for UserDefaults { fn serialize(&self, serializer: S) -> Result where S: Serializer { let mut map: BTreeMap = BTreeMap::new(); + map.insert("is_first_launch".into(), Value::Bool(self.is_first_launch)); map.insert("pruning".into(), Value::String(self.pruning.as_str().into())); map.insert("tracing".into(), Value::Bool(self.tracing)); map.insert("fat_db".into(), Value::Bool(self.fat_db));