pub fn prune(&mut self, current_slot: Slot) {
        let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_PRUNE);

        // Taking advantage of saturating subtraction on `Slot`.
        let lowest_permissible_slot = current_slot - Slot::from(SLOTS_RETAINED);

        // No need to prune if the lowest permissible slot has not changed and the queue length is
        // less than the maximum
        if self.lowest_permissible_slot == lowest_permissible_slot
            && self.maps.len() <= SLOTS_RETAINED
        {
            return;
        }

        self.lowest_permissible_slot = lowest_permissible_slot;

        // Remove any maps that are definitely expired.
        self.maps
            .retain(|slot, _map| *slot >= lowest_permissible_slot);

        // If we have too many maps, remove the lowest amount to ensure we only have
        // `SLOTS_RETAINED` left.
        if self.maps.len() > SLOTS_RETAINED {
            let mut slots = self
                .maps
                .iter()
                .map(|(slot, _map)| *slot)
                .collect::<Vec<_>>();
            // Sort is generally pretty slow, however `SLOTS_RETAINED` is quite low so it should be
            // negligible.
            slots.sort_unstable();
            slots
                .into_iter()
                .take(self.maps.len().saturating_sub(SLOTS_RETAINED))
                .for_each(|slot| {
                    self.maps.remove(&slot);
                })
        }
    }
/// Removes any attestations with a slot lower than `current_slot` and bars any future
/// attestations with a slot lower than `current_slot - SLOTS_RETAINED`.
Removes any attestations with a slot lower than `current_slot` and bars any future
attestations with a slot lower than `current_slot - SLOTS_RETAINED`.
Removes any attestations with a slot lower than ` current_slot ` and bars any future attestations with a slot lower than ` current_slot - SLOTS_RETAINED ` .
pub fn prune(&mut self, current_slot: Slot) {
        let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_PRUNE);
        // Taking advantage of saturating subtraction on `Slot`.
        let lowest_permissible_slot = current_slot - Slot::from(SLOTS_RETAINED);
        // No need to prune if the lowest permissible slot has not changed and the queue length is
        // less than the maximum
        if self.lowest_permissible_slot == lowest_permissible_slot
            && self.maps.len() <= SLOTS_RETAINED
        {
            return;
        }
        self.lowest_permissible_slot = lowest_permissible_slot;
        // Remove any maps that are definitely expired.
        self.maps
            .retain(|slot, _map| *slot >= lowest_permissible_slot);
        // If we have too many maps, remove the lowest amount to ensure we only have
        // `SLOTS_RETAINED` left.
        if self.maps.len() > SLOTS_RETAINED {
            let mut slots = self
                .maps
                .iter()
                .map(|(slot, _map)| *slot)
                .collect::<Vec<_>>();
            // Sort is generally pretty slow, however `SLOTS_RETAINED` is quite low so it should be
            // negligible.
            slots.sort_unstable();
            slots
                .into_iter()
                .take(self.maps.len().saturating_sub(SLOTS_RETAINED))
                .for_each(|slot| {
                    self.maps.remove(&slot);
                })
        }
    }
pub fn prune ( & mut self , current_slot : Slot ) { let _timer = metrics :: start_timer ( & metrics :: ATTESTATION_PROCESSING_AGG_POOL_PRUNE ) ; // Taking advantage of saturating subtraction on `Slot`. let lowest_permissible_slot = current_slot - Slot :: from ( SLOTS_RETAINED ) ; // No need to prune if the lowest permissible slot has not changed and the queue length is // less than the maximum if self . lowest_permissible_slot == lowest_permissible_slot && self . maps . len ( ) <= SLOTS_RETAINED { return ; } self . lowest_permissible_slot = lowest_permissible_slot ; // Remove any maps that are definitely expired. self . maps . retain ( | slot , _map | * slot >= lowest_permissible_slot ) ; // If we have too many maps, remove the lowest amount to ensure we only have // `SLOTS_RETAINED` left. if self . maps . len ( ) > SLOTS_RETAINED { let mut slots = self . maps . iter ( ) . map ( | ( slot , _map ) | * slot ) . collect :: < Vec < _ > > ( ) ; // Sort is generally pretty slow, however `SLOTS_RETAINED` is quite low so it should be // negligible. slots . sort_unstable ( ) ; slots . into_iter ( ) . take ( self . maps . len ( ) . saturating_sub ( SLOTS_RETAINED ) ) . for_each ( | slot | { self . maps . remove ( & slot ) ; } ) } }
Removes any attestations with a slot lower than `current_slot` and bars any future
attestations with a slot lower than `current_slot - SLOTS_RETAINED`.
Removes any attestations with a slot lower than ` current_slot ` and bars any future attestations with a slot lower than ` current_slot - SLOTS_RETAINED ` .
&mut self
current_slot
Slot