Skip to content

Commit

Permalink
Remove is_{leader,helper} helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mendess committed Jan 3, 2025
1 parent 0f897a0 commit 16be6a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 33 deletions.
29 changes: 16 additions & 13 deletions crates/daphne-server/src/roles/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,22 @@ impl DapAggregator for crate::App {
) -> Result<(), DapError> {
let expiration_time = task_config.not_after;

if self.service_config.role.is_leader() {
self.kv()
.put_with_expiration::<kv::prefix::TaskConfig>(
task_id,
task_config,
expiration_time,
)
.await
.map_err(|e| fatal_error!(err = ?e, "failed to put the a task config in kv"))?;
} else {
self.kv()
.only_cache_put::<kv::prefix::TaskConfig>(task_id, task_config)
.await;
match self.service_config.role {
daphne::constants::DapAggregatorRole::Leader => {
self.kv()
.put_with_expiration::<kv::prefix::TaskConfig>(
task_id,
task_config,
expiration_time,
)
.await
.map_err(|e| fatal_error!(err = ?e, "failed to put the a task config in kv"))?;
}
daphne::constants::DapAggregatorRole::Helper => {
self.kv()
.only_cache_put::<kv::prefix::TaskConfig>(task_id, task_config)
.await;
}
}
Ok(())
}
Expand Down
20 changes: 0 additions & 20 deletions crates/daphne/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ pub enum DapRole {
Helper,
}

impl DapRole {
pub fn is_leader(self) -> bool {
self == Self::Leader
}

pub fn is_helper(self) -> bool {
self == Self::Helper
}
}

impl FromStr for DapRole {
type Err = String;

Expand Down Expand Up @@ -119,16 +109,6 @@ pub enum DapAggregatorRole {
Helper,
}

impl DapAggregatorRole {
pub fn is_leader(self) -> bool {
self == Self::Leader
}

pub fn is_helper(self) -> bool {
self == Self::Helper
}
}

impl FromStr for DapAggregatorRole {
type Err = String;

Expand Down

0 comments on commit 16be6a7

Please sign in to comment.