Skip to content

Commit 3f9f5a1

Browse files
committed
Remove is_{leader,helper} helpers
1 parent 64b9641 commit 3f9f5a1

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

crates/daphne-server/src/roles/aggregator.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,22 @@ impl DapAggregator for crate::App {
216216
) -> Result<(), DapError> {
217217
let expiration_time = task_config.not_after;
218218

219-
if self.service_config.role.is_leader() {
220-
self.kv()
221-
.put_with_expiration::<kv::prefix::TaskConfig>(
222-
task_id,
223-
task_config,
224-
expiration_time,
225-
)
226-
.await
227-
.map_err(|e| fatal_error!(err = ?e, "failed to put the a task config in kv"))?;
228-
} else {
229-
self.kv()
230-
.only_cache_put::<kv::prefix::TaskConfig>(task_id, task_config)
231-
.await;
219+
match self.service_config.role {
220+
daphne::constants::DapAggregatorRole::Leader => {
221+
self.kv()
222+
.put_with_expiration::<kv::prefix::TaskConfig>(
223+
task_id,
224+
task_config,
225+
expiration_time,
226+
)
227+
.await
228+
.map_err(|e| fatal_error!(err = ?e, "failed to put the a task config in kv"))?;
229+
}
230+
daphne::constants::DapAggregatorRole::Helper => {
231+
self.kv()
232+
.only_cache_put::<kv::prefix::TaskConfig>(task_id, task_config)
233+
.await;
234+
}
232235
}
233236
Ok(())
234237
}

crates/daphne/src/constants.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ pub enum DapRole {
7575
Helper,
7676
}
7777

78-
impl DapRole {
79-
pub fn is_leader(self) -> bool {
80-
self == Self::Leader
81-
}
82-
83-
pub fn is_helper(self) -> bool {
84-
self == Self::Helper
85-
}
86-
}
87-
8878
impl FromStr for DapRole {
8979
type Err = String;
9080

@@ -119,16 +109,6 @@ pub enum DapAggregatorRole {
119109
Helper,
120110
}
121111

122-
impl DapAggregatorRole {
123-
pub fn is_leader(self) -> bool {
124-
self == Self::Leader
125-
}
126-
127-
pub fn is_helper(self) -> bool {
128-
self == Self::Helper
129-
}
130-
}
131-
132112
impl FromStr for DapAggregatorRole {
133113
type Err = String;
134114

0 commit comments

Comments
 (0)