Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions script/bin/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,22 +1002,23 @@ where
}

// Run the operator, indefinitely.
async fn run(self) {
async fn run(self) -> Result<()> {
let job_interval = Duration::from_secs(get_job_interval_mins() * 60);

tokio::select! {
res = self.run_once() => {
if let Err(e) = res {
error!("Error during `run_once`: {:?}", e);
return;
return Err(anyhow::anyhow!("Error during `run_once`"));
}
},
_ = tokio::time::sleep(Duration::from_secs(LOOP_TIMEOUT_MINS * 60)) => {
info!("Timed out after {:?} minutes", LOOP_TIMEOUT_MINS);
return Err(anyhow::anyhow!("Timed out after {:?} minutes", LOOP_TIMEOUT_MINS));
}
}

info!("Sleeping for {:?} minutes", job_interval.as_secs() / 60);
Ok(())
}
}

Expand Down Expand Up @@ -1102,15 +1103,15 @@ async fn main() -> Result<()> {
.unwrap_or(SignerMode::Local);
let config = ChainConfig::fetch().expect("Failed to fetch chain config");

match signer_mode {
let run_result = match signer_mode {
SignerMode::Local => run_with_signer(config).await,
SignerMode::Kms => run_with_kms(config).await,
}
};

Ok(())
run_result
}

async fn run_with_signer(config: Vec<ChainConfig>) {
async fn run_with_signer(config: Vec<ChainConfig>) -> Result<()> {
let mut operator = SP1VectorOperator::new(SignerMode::Local).await;

let signer: PrivateKeySigner = env::var("PRIVATE_KEY")
Expand All @@ -1129,7 +1130,7 @@ async fn run_with_signer(config: Vec<ChainConfig>) {
operator.run().await
}

async fn run_with_kms(config: Vec<ChainConfig>) {
async fn run_with_kms(config: Vec<ChainConfig>) -> Result<()> {
let mut operator = SP1VectorOperator::new(SignerMode::Kms).await;

for c in config {
Expand Down
Loading