Skip to content

Commit d2ce2ec

Browse files
author
Dev Kalra
authored
feat(fortuna): add a cli arg to run keeper (#1517)
* optional run keeper * update comment * instead of flag use the keeper key file * update version * rename method
1 parent 2095da3 commit d2ce2ec

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

apps/fortuna/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "5.0.0"
3+
version = "5.1.0"
44
edition = "2021"
55

66
[dependencies]

apps/fortuna/src/command/run.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
127127
.provider_config
128128
.as_ref()
129129
.map(|path| ProviderConfig::load(&path).expect("Failed to load provider config"));
130-
let private_key = opts.load_private_key()?;
131130
let secret = opts.randomness.load_secret()?;
132131
let (tx_exit, rx_exit) = watch::channel(false);
133132

@@ -141,7 +140,6 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
141140
.as_ref()
142141
.map(|c| c.get_sorted_commitments())
143142
.unwrap_or_else(|| Vec::new());
144-
println!("{} {:?}", chain_id, provider_commitments);
145143

146144
let provider_info = contract.get_provider_info(opts.provider).call().await?;
147145
let latest_metadata =
@@ -212,7 +210,10 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
212210

213211
Ok::<(), Error>(())
214212
});
215-
spawn(run_keeper(chains.clone(), config, private_key));
213+
214+
if let Some(keeper_private_key) = opts.load_keeper_private_key()? {
215+
spawn(run_keeper(chains.clone(), config, keeper_private_key));
216+
}
216217

217218
run_api(opts.addr.clone(), chains, rx_exit).await?;
218219

apps/fortuna/src/config/run.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,20 @@ pub struct RunOptions {
3636
#[arg(env = "FORTUNA_PROVIDER")]
3737
pub provider: Address,
3838

39-
/// Path to a file containing a 20-byte (40 char) hex encoded Ethereum private key.
39+
/// If provided, the keeper will run alongside the Fortuna API service.
40+
/// It should be a path to a file containing a 20-byte (40 char) hex encoded Ethereum private key.
4041
/// This key is required to submit transactions for entropy callback requests.
4142
/// This key should not be a registered provider.
4243
#[arg(long = "keeper-private-key")]
4344
#[arg(env = "KEEPER_PRIVATE_KEY")]
44-
pub keeper_private_key_file: String,
45+
pub keeper_private_key_file: Option<String>,
4546
}
4647

4748
impl RunOptions {
48-
pub fn load_private_key(&self) -> Result<String> {
49-
return Ok((fs::read_to_string(&self.keeper_private_key_file))?);
49+
pub fn load_keeper_private_key(&self) -> Result<Option<String>> {
50+
if let Some(ref keeper_private_key_file) = self.keeper_private_key_file {
51+
return Ok(Some(fs::read_to_string(keeper_private_key_file)?));
52+
}
53+
return Ok(None);
5054
}
5155
}

0 commit comments

Comments
 (0)