Skip to content

Commit ccdddf4

Browse files
authored
CLI: Avoid unwrapping (#162)
- If calling `state.detect_stall` is Err, the keeper will panic, then stops running. - To keep running, we should avoid unwrapping
1 parent 25a5b7d commit ccdddf4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cli/src/keeper/keeper_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ pub async fn startup_keeper(
377377
continue;
378378
}
379379

380-
epoch_stall = !run_operations || result.unwrap();
380+
epoch_stall = !run_operations || result.unwrap_or(false);
381381

382382
emit_heartbeat(
383383
tick,

cli/src/keeper/keeper_state.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,14 @@ impl KeeperState {
385385
Ok(*state)
386386
}
387387

388+
/// Detects if the current epoch is in a stalled state.
389+
///
390+
/// # Stall Detection
391+
/// 1. **Epoch Completed**: If `is_epoch_completed` is true
392+
/// 2. **Vote State**: When the current state is `State::Vote`
393+
/// 3. **Post-Vote Cooldown**: When in `State::PostVoteCooldown`
394+
/// 4. **Insufficient Rewards**: During `State::Distribute`, if total rewards to be distributed
395+
/// are less than **10,000** (dust threshold)
388396
pub async fn detect_stall(&mut self, handler: &CliHandler) -> Result<bool> {
389397
if self.is_epoch_completed {
390398
return Ok(true);

0 commit comments

Comments
 (0)