Fix save command return value

This commit is contained in:
Aditya Kulkarni
2019-10-19 20:29:17 -07:00
parent c3af5a1ca2
commit e4f00a78d5
2 changed files with 20 additions and 11 deletions

View File

@@ -331,23 +331,17 @@ impl LightClient {
}
}
pub fn do_save(&self) -> String {
pub fn do_save(&self) -> Result<(), String> {
let mut file_buffer = BufWriter::with_capacity(
1_000_000, // 1 MB write buffer
File::create(self.config.get_wallet_path()).unwrap());
match self.wallet.write().unwrap().write(&mut file_buffer) {
Ok(_) => {
info!("Saved wallet");
let response = object!{
"result" => "success"
};
response.pretty(2)
},
Ok(_) => Ok(()),
Err(e) => {
let err = format!("ERR: {}", e);
error!("{}", err);
err
Err(e.to_string())
}
}
}