Skip to content

Commit 74618d4

Browse files
authored
Merge pull request #294 from AdExNetwork/copy-on-validator-id
Derive Copy for ValidatorId
2 parents f7665c5 + db97b2d commit 74618d4

File tree

7 files changed

+12
-18
lines changed

7 files changed

+12
-18
lines changed

adapter/src/dummy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Adapter for DummyAdapter {
103103

104104
match identity {
105105
Some((id, _)) => Ok(Session {
106-
uid: self.session_tokens[id].clone(),
106+
uid: self.session_tokens[id],
107107
era: 0,
108108
}),
109109
None => Err(AdapterError::Authentication(format!(

primitives/src/validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub enum ValidatorError {
1414
InvalidTransition,
1515
}
1616

17-
#[derive(Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
17+
#[derive(Deserialize, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
1818
#[serde(transparent)]
1919
pub struct ValidatorId(
2020
#[serde(

sentry/src/db/event_aggregate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub async fn insert_event_aggregate(
177177
data.push(EventData {
178178
id: channel_id.to_owned(),
179179
event_type: event_type.clone(),
180-
earner: Some(earner.clone()),
180+
earner: Some(*earner),
181181
event_count: event_count.to_owned(),
182182
event_payout: event_payout.clone(),
183183
});

sentry/src/event_reducer.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ pub(crate) fn reduce(
2727
initial_aggr.events.insert("CLICK".to_owned(), merge);
2828
}
2929
Event::Close => {
30-
let creator = channel.creator.clone();
3130
let close_event = AggregateEvents {
32-
event_counts: Some(vec![(creator.clone(), 1.into())].into_iter().collect()),
33-
event_payouts: vec![(creator, channel.deposit_amount.clone())]
31+
event_counts: Some(vec![(channel.creator, 1.into())].into_iter().collect()),
32+
event_payouts: vec![(channel.creator, channel.deposit_amount.clone())]
3433
.into_iter()
3534
.collect(),
3635
};

sentry/src/routes/event_aggregate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub async fn list_channel_event_aggregates<A: Adapter>(
3232
let from = if channel.spec.validators.find(&auth.uid).is_some() {
3333
None
3434
} else {
35-
Some(auth.uid.clone())
35+
Some(auth.uid)
3636
};
3737

3838
let event_aggregates = list_event_aggregates(

validator_worker/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async fn validator_tick<A: Adapter + 'static>(
197197
config: &Config,
198198
logger: &Logger,
199199
) -> Result<(ChannelId, Box<dyn Debug>), ValidatorWorkerError<A::AdapterError>> {
200-
let whoami = adapter.whoami().clone();
200+
let whoami = *adapter.whoami();
201201

202202
// Cloning the `Logger` is cheap, see documentation for more info
203203
let sentry = SentryApi::init(adapter, channel.clone(), &config, logger.clone())

validator_worker/src/sentry_interface.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,8 @@ impl<A: Adapter + 'static> SentryApi<A> {
116116
}
117117
None => Err(Error::MissingWhoamiInChannelValidators {
118118
channel: channel.id,
119-
validators: channel
120-
.spec
121-
.validators
122-
.iter()
123-
.map(|v| v.id.clone())
124-
.collect(),
125-
whoami: adapter.whoami().clone(),
119+
validators: channel.spec.validators.iter().map(|v| v.id).collect(),
120+
whoami: *adapter.whoami(),
126121
}),
127122
}
128123
}
@@ -242,12 +237,12 @@ async fn propagate_to<A: Adapter>(
242237
.json(&body)
243238
.send()
244239
.await
245-
.map_err(|e| (validator.id.clone(), Error::Request(e)))?
240+
.map_err(|e| (validator.id, Error::Request(e)))?
246241
.json()
247242
.await
248-
.map_err(|e| (validator.id.clone(), Error::Request(e)))?;
243+
.map_err(|e| (validator.id, Error::Request(e)))?;
249244

250-
Ok(validator.id.clone())
245+
Ok(validator.id)
251246
}
252247

253248
pub async fn all_channels(

0 commit comments

Comments
 (0)