Skip to content

Commit

Permalink
User_defaults now contains serialization for is_first_launch paramete…
Browse files Browse the repository at this point in the history
…r; (openethereum#6068)

Solved the "TraceDB resync required" issue when trying to use "--tracing on" option just after a DB kill operation;
  • Loading branch information
Neurone authored and arkpar committed Jul 18, 2017
1 parent 801fcf3 commit 319a01b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parity/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
1 change: 1 addition & 0 deletions parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> 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;
Expand Down
1 change: 1 addition & 0 deletions parity/user_defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl Serialize for UserDefaults {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer {
let mut map: BTreeMap<String, Value> = 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));
Expand Down

0 comments on commit 319a01b

Please sign in to comment.