Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion akd/src/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ where
// Ignore states in storage which are ahead of the current directory epoch
user_data.retain(|vs| vs.epoch <= current_epoch);
// Reverse sort from highest epoch to lowest
user_data.sort_by(|a, b| b.epoch.cmp(&a.epoch));
user_data.sort_by_key(|b| std::cmp::Reverse(b.epoch));

// Apply filters specified by HistoryParams struct
user_data = match params {
Expand Down
2 changes: 1 addition & 1 deletion akd/src/storage/cache/high_parallelism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl TimedCache {
.iter()
.map(|kv| (kv.key().clone(), kv.value().expiration))
.collect::<Vec<_>>();
keys_and_expiration.sort_by(|(_, a), (_, b)| a.cmp(b));
keys_and_expiration.sort_by_key(|(_, a)| *a);
// take `num_clean` old entries and remove them
for key in keys_and_expiration
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion akd/src/storage/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Database for AsyncInMemoryDatabase {
if let Some(result) = self.user_info.get(&username.0) {
let mut results: Vec<ValueState> = result.values().cloned().collect::<Vec<_>>();
// return ordered by epoch (from smallest -> largest)
results.sort_by(|a, b| a.epoch.cmp(&b.epoch));
results.sort_by_key(|a| a.epoch);

Ok(KeyData { states: results })
} else {
Expand Down
8 changes: 2 additions & 6 deletions akd/src/storage/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ async fn test_batch_get_items<Ns: Database>(storage: &Ns) {

let mut data = Vec::new();

let mut epoch = 1;
for value in rand_users.iter() {
for (epoch, value) in (1..).zip(rand_users.iter()) {
for user in rand_users.iter() {
data.push(DbRecord::ValueState(ValueState {
value: AkdValue(value.clone()),
Expand All @@ -158,7 +157,6 @@ async fn test_batch_get_items<Ns: Database>(storage: &Ns) {
username: AkdLabel(user.clone()),
}));
}
epoch += 1;
}

let tic = Instant::now();
Expand Down Expand Up @@ -312,8 +310,7 @@ async fn test_transactions<S: Database>(storage: &StorageManager<S>) {

let mut data = Vec::new();

let mut epoch = 1;
for value in rand_users.iter() {
for (epoch, value) in (1..).zip(rand_users.iter()) {
for user in rand_users.iter() {
data.push(DbRecord::ValueState(ValueState {
value: AkdValue(value.clone()),
Expand All @@ -326,7 +323,6 @@ async fn test_transactions<S: Database>(storage: &StorageManager<S>) {
username: AkdLabel(user.clone()),
}));
}
epoch += 1;
}

data.push(DbRecord::Azks(Azks {
Expand Down
2 changes: 1 addition & 1 deletion akd/src/storage/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Transaction {

// sort all the value lists by epoch
for (_k, v) in results.iter_mut() {
v.sort_unstable_by(|a, b| a.epoch.cmp(&b.epoch));
v.sort_unstable_by_key(|a| a.epoch);
}

results
Expand Down
2 changes: 1 addition & 1 deletion examples/src/whatsapp_kt_auditor/auditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub(crate) async fn audit_epoch(blob: akd::local_auditing::AuditBlob) -> Result<
}

pub(crate) fn display_audit_proofs_info(info: &mut [EpochSummary]) -> Result<String> {
info.sort_by(|a, b| a.name.epoch.cmp(&b.name.epoch));
info.sort_by_key(|a| a.name.epoch);
if info.is_empty() {
bail!("There are no epochs present in the storage repository");
}
Expand Down
Loading