Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
fix: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
seerscode committed May 9, 2019
1 parent 696bc7b commit 502d47e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions core/consensus/slots/src/aux_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub fn check_equivocation<C, H, P>(
}
}

// TODO: Having two vectors is super ugly, but I don't know a way around.
// TODO: Is there a better way?
let mut keys_to_delete = vec![];
let mut keys_as_slice_to_delete = vec![];

Expand All @@ -105,19 +105,13 @@ pub fn check_equivocation<C, H, P>(
let first_slot = slot - PRUNING_BOUND;
let last_slot = slot - MAX_SLOT_CAPACITY;

for _ in first_slot..last_slot {
keys_to_delete.push(prefix.clone());
}

let mut s = first_slot;
for p in keys_to_delete.iter_mut() {
for s in first_slot..last_slot {
let mut p = prefix.clone();
s.using_encoded(|s| p.extend(s));
s += 1;
keys_to_delete.push(p);
}

for p in keys_to_delete.iter() {
keys_as_slice_to_delete.push(p.as_slice());
}
keys_as_slice_to_delete.extend(keys_to_delete.iter().map(|p| p.as_slice()));
}

v.push((header, signer));
Expand Down

0 comments on commit 502d47e

Please sign in to comment.