Save in non-interactive mode

This commit is contained in:
Aditya Kulkarni 2019-10-18 15:38:16 -07:00
parent 4518965a41
commit 5905ef728b
2 changed files with 18 additions and 4 deletions

View File

@ -333,10 +333,20 @@ impl LightClient {
1_000_000, // 1 MB write buffer
File::create(self.config.get_wallet_path()).unwrap());
self.wallet.write(&mut file_buffer).unwrap();
info!("Saved wallet");
format!("Saved Wallet")
match self.wallet.write(&mut file_buffer) {
Ok(_) => {
info!("Saved wallet");
let response = object!{
"result" => "success"
};
response.pretty(2)
},
Err(e) => {
let err = format!("ERR: {}", e);
error!("{}", err);
err
}
}
}
pub fn get_server_uri(&self) -> http::Uri {

View File

@ -137,6 +137,10 @@ pub fn main() {
error!("{}", e);
}
}
// Save before exit
command_tx.send(("save".to_string(), vec![])).unwrap();
resp_rx.recv().unwrap();
}
}