* Use try!/map_err instead of match

* Use jsonrpc_core for serializing/deserializing rpc messages
* Factor out unwraps
* Remove mem::replace
* Add nicer formating of ConfirmationRequests
This commit is contained in:
Kristoffer Ström
2016-09-30 15:30:17 +02:00
committed by arkpar
parent 273d7c00c3
commit 7a176094d5
9 changed files with 162 additions and 137 deletions

View File

@@ -43,6 +43,8 @@ use presale::ImportWallet;
use account::{AccountCmd, NewAccount, ImportAccounts, ImportFromGethAccounts};
use snapshot::{self, SnapshotCommand};
const AUTHCODE_FILENAME: &'static str = "authcodes";
#[derive(Debug, PartialEq)]
pub enum Cmd {
Run(RunCmd),
@@ -62,7 +64,7 @@ pub enum Cmd {
authfile: PathBuf
},
SignerReject {
id: usize,
id: Option<usize>,
port: u16,
authfile: PathBuf
},
@@ -124,15 +126,14 @@ impl Configuration {
=======
} else if self.args.cmd_signer {
let mut authfile = PathBuf::from(signer_conf.signer_path);
authfile.push("authcodes");
authfile.push(AUTHCODE_FILENAME);
if self.args.cmd_new_token {
Cmd::SignerToken(dirs.signer)
} else if self.args.cmd_sign {
let pwfile = match self.args.flag_password.get(0) {
Some(pwfile) => Some(PathBuf::from(pwfile)),
None => None,
};
let pwfile = self.args.flag_password.get(0).map(|pwfile| {
PathBuf::from(pwfile)
});
Cmd::SignerSign {
id: self.args.arg_id,
pwfile: pwfile,
@@ -141,8 +142,7 @@ impl Configuration {
}
} else if self.args.cmd_reject {
Cmd::SignerReject {
// id is a required field for this command
id: self.args.arg_id.unwrap(),
id: self.args.arg_id,
port: signer_conf.port,
authfile: authfile,
}