mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 05:44:44 +00:00
Use slice.is_sorted now that it's stable (#7507)
Use slice.is_sorted which was stabilised in Rust 1.82.0 I thought there would be more places we could use this, but it seems we often want to check strict monotonicity (i.e. sorted + no duplicates)
This commit is contained in:
@@ -2671,10 +2671,7 @@ where
|
|||||||
mut latest_block_hash: Option<SignedBeaconBlockHash>,
|
mut latest_block_hash: Option<SignedBeaconBlockHash>,
|
||||||
sync_committee_strategy: SyncCommitteeStrategy,
|
sync_committee_strategy: SyncCommitteeStrategy,
|
||||||
) -> AddBlocksResult<E> {
|
) -> AddBlocksResult<E> {
|
||||||
assert!(
|
assert!(slots.is_sorted(), "Slots have to be in ascending order");
|
||||||
slots.windows(2).all(|w| w[0] <= w[1]),
|
|
||||||
"Slots have to be sorted"
|
|
||||||
); // slice.is_sorted() isn't stabilized at the moment of writing this
|
|
||||||
let mut block_hash_from_slot: HashMap<Slot, SignedBeaconBlockHash> = HashMap::new();
|
let mut block_hash_from_slot: HashMap<Slot, SignedBeaconBlockHash> = HashMap::new();
|
||||||
let mut state_hash_from_slot: HashMap<Slot, BeaconStateHash> = HashMap::new();
|
let mut state_hash_from_slot: HashMap<Slot, BeaconStateHash> = HashMap::new();
|
||||||
for slot in slots {
|
for slot in slots {
|
||||||
@@ -2714,10 +2711,7 @@ where
|
|||||||
mut latest_block_hash: Option<SignedBeaconBlockHash>,
|
mut latest_block_hash: Option<SignedBeaconBlockHash>,
|
||||||
sync_committee_strategy: SyncCommitteeStrategy,
|
sync_committee_strategy: SyncCommitteeStrategy,
|
||||||
) -> AddBlocksResult<E> {
|
) -> AddBlocksResult<E> {
|
||||||
assert!(
|
assert!(slots.is_sorted(), "Slots have to be in ascending order");
|
||||||
slots.windows(2).all(|w| w[0] <= w[1]),
|
|
||||||
"Slots have to be sorted"
|
|
||||||
); // slice.is_sorted() isn't stabilized at the moment of writing this
|
|
||||||
let mut block_hash_from_slot: HashMap<Slot, SignedBeaconBlockHash> = HashMap::new();
|
let mut block_hash_from_slot: HashMap<Slot, SignedBeaconBlockHash> = HashMap::new();
|
||||||
let mut state_hash_from_slot: HashMap<Slot, BeaconStateHash> = HashMap::new();
|
let mut state_hash_from_slot: HashMap<Slot, BeaconStateHash> = HashMap::new();
|
||||||
for slot in slots {
|
for slot in slots {
|
||||||
|
|||||||
Reference in New Issue
Block a user