diff --git a/runtime/src/ancestors.rs b/runtime/src/ancestors.rs index bfef0925ce..a522cceded 100644 --- a/runtime/src/ancestors.rs +++ b/runtime/src/ancestors.rs @@ -1,5 +1,5 @@ use solana_sdk::clock::Slot; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; pub type AncestorsForSerialization = HashMap; @@ -9,7 +9,7 @@ pub struct Ancestors { slots: Vec>, count: usize, max: Slot, - large_range_slots: HashMap, + large_range_slots: HashSet, } // some tests produce ancestors ranges that are too large such @@ -28,7 +28,7 @@ impl From> for Ancestors { }); let range = result.range(); if range > ANCESTORS_HASH_MAP_SIZE { - result.large_range_slots = source.into_iter().collect(); + result.large_range_slots = source.into_iter().map(|(slot, _)| slot).collect(); result.min = 0; result.max = 0; } else { @@ -59,8 +59,7 @@ impl From<&HashMap> for Ancestors { }); let range = result.range(); if range > ANCESTORS_HASH_MAP_SIZE { - result.large_range_slots = - source.iter().map(|(slot, size)| (*slot, *size)).collect(); + result.large_range_slots = source.iter().map(|(slot, _size)| *slot).collect(); result.min = 0; result.max = 0; } else { @@ -98,7 +97,7 @@ impl Ancestors { .filter_map(|(size, i)| i.map(|_| size as u64 + self.min)) .collect::>() } else { - self.large_range_slots.keys().copied().collect::>() + self.large_range_slots.iter().copied().collect::>() } } @@ -137,7 +136,7 @@ impl Ancestors { let slot = self.slot_index(slot); self.slots[slot].is_some() } else { - self.large_range_slots.contains_key(slot) + self.large_range_slots.contains(slot) } } @@ -209,7 +208,7 @@ pub mod tests { } self.slots[slot as usize] = Some(size); } else { - self.large_range_slots.insert(slot, size); + self.large_range_slots.insert(slot); } } }