Skip to content

Commit

Permalink
add get_cycle_duration
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Mar 24, 2024
1 parent 4a5e538 commit 49ce9c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/encointer-api-client-extension/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub trait SchedulerApi {
phase: CeremonyPhaseType,
maybe_at: Option<Hash>,
) -> Result<Moment>;
async fn get_cycle_duration(&self, maybe_at: Option<Hash>) -> Result<Moment>;
async fn get_start_of_attesting_phase(&self, maybe_at: Option<Hash>) -> Result<Moment>;
}

Expand Down Expand Up @@ -47,6 +48,15 @@ impl SchedulerApi for Api {
.ok_or_else(|| ApiClientError::Other("Couldn't get PhaseDuration".into()))
}

async fn get_cycle_duration(&self, maybe_at: Option<Hash>) -> Result<Moment> {
let parts = tokio::try_join!(
self.get_phase_duration(CeremonyPhaseType::Registering, maybe_at),
self.get_phase_duration(CeremonyPhaseType::Assigning, maybe_at),
self.get_phase_duration(CeremonyPhaseType::Attesting, maybe_at)
)?;
Ok(parts.0 + parts.1 + parts.2)
}

async fn get_start_of_attesting_phase(&self, maybe_at: Option<Hash>) -> Result<Moment> {
let next_phase_timestamp = self.get_next_phase_timestamp(maybe_at).await?;

Expand Down

0 comments on commit 49ce9c1

Please sign in to comment.