Flag to only run coconut-related functionalities (#824)

This commit is contained in:
Jędrzej Stuczyński
2021-10-19 10:30:07 +01:00
committed by GitHub
parent 4307756719
commit dcc9b856d7
+21 -1
View File
@@ -58,6 +58,9 @@ const API_VALIDATORS_ARG: &str = "api-validators";
#[cfg(feature = "coconut")]
const KEYPAIR_ARG: &str = "keypair";
#[cfg(feature = "coconut")]
const COCONUT_ONLY_FLAG: &str = "coconut-only";
const EPOCH_LENGTH_ARG: &str = "epoch-length";
const FIRST_REWARDING_EPOCH_ARG: &str = "first-epoch";
const REWARDING_MONITOR_THRESHOLD_ARG: &str = "monitor-threshold";
@@ -162,11 +165,15 @@ fn parse_args<'a>() -> ArgMatches<'a> {
);
#[cfg(feature = "coconut")]
let base_app = base_app.arg(
let base_app = base_app.arg(
Arg::with_name(KEYPAIR_ARG)
.help("Path to the secret key file")
.takes_value(true)
.long(KEYPAIR_ARG),
).arg(
Arg::with_name(COCONUT_ONLY_FLAG)
.help("Flag to indicate whether validator api should only be used for credential issuance with no blockchain connection")
.long(COCONUT_ONLY_FLAG),
);
base_app.get_matches()
@@ -429,11 +436,24 @@ async fn main() -> Result<()> {
};
let matches = parse_args();
let config = override_config(config, &matches);
// if we just wanted to write data to the config, exit
if matches.is_present(WRITE_CONFIG_ARG) {
return Ok(());
}
#[cfg(feature = "coconut")]
if matches.is_present(COCONUT_ONLY_FLAG) {
// this simplifies everything - we just want to run coconut things
return rocket::build()
.attach(setup_cors()?)
.attach(InternalSignRequest::stage(config.keypair()))
.launch()
.await
.map_err(|err| err.into());
}
let liftoff_notify = Arc::new(Notify::new());
// let's build our rocket!