fix deadlock for restore[skip audit]
@@ -56,6 +56,8 @@ impl DatabaseRestore for Executor {
/// Restart the client with a new backend
fn restore_db(&self, new_db: &str) -> Result<(), ::error::Error> {
trace!("Replacing client database with {:?}", new_db);
+ let header;
+ {
let mut state_db = self.state_db.write();
let db = self.db.write();
@@ -68,14 +70,14 @@ impl DatabaseRestore for Executor {
);
// replace executor
- // *chain = Arc::new(BlockChain::new(self.config.blockchain.clone(), &[], db.clone()));
- let header = match get_current_header(&*db.clone()) {
+ header = match get_current_header(&*db.clone()) {
Some(header) => header,
_ => {
trace!("Get header failed.");
return Err(Error::PowInvalid);
}
};
+ }
self.replace_executor(header, false);
