pub fn insert(&mut self, attestation: &Attestation<E>) -> Result<InsertOutcome, Error> {
        let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_INSERT);
        let slot = attestation.data.slot;
        let lowest_permissible_slot = self.lowest_permissible_slot;

        // Reject any attestations that are too old.
        if slot < lowest_permissible_slot {
            return Err(Error::SlotTooLow {
                slot,
                lowest_permissible_slot,
            });
        }

        let lock_timer =
            metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_MAPS_WRITE_LOCK);
        drop(lock_timer);

        let outcome = if let Some(map) = self.maps.get_mut(&slot) {
            map.insert(attestation)
        } else {
            let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_CREATE_MAP);
            // To avoid re-allocations, try and determine a rough initial capacity for the new item
            // by obtaining the mean size of all items in earlier epoch.
            let (count, sum) = self
                .maps
                .iter()
                // Only include epochs that are less than the given slot in the average. This should
                // generally avoid including recent epochs that are still "filling up".
                .filter(|(map_slot, _item)| **map_slot < slot)
                .map(|(_slot, map)| map.len())
                .fold((0, 0), |(count, sum), len| (count + 1, sum + len));

            // Use the mainnet default committee size if we can't determine an average.
            let initial_capacity = sum.checked_div(count).unwrap_or(128);

            let mut item = AggregatedAttestationMap::new(initial_capacity);
            let outcome = item.insert(attestation);
            self.maps.insert(slot, item);

            outcome
        };

        self.prune(slot);

        outcome
    }
/// Insert an attestation into `self`, aggregating it into the pool.
///
/// The given attestation (`a`) must only have one signature and have an
/// `attestation.data.slot` that is not lower than `self.lowest_permissible_slot`.
///
/// The pool may be pruned if the given `attestation.data` has a slot higher than any
/// previously seen.
Insert an attestation into `self`, aggregating it into the pool.

The pool may be pruned if the given `attestation.data` has a slot higher than any
previously seen.
Insert an attestation into ` self ` aggregating it into the pool . The pool may be pruned if the given ` attestation . data ` has a slot higher than any previously seen .
pub fn insert(&mut self, attestation: &Attestation<E>) -> Result<InsertOutcome, Error> {
        let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_INSERT);
        let slot = attestation.data.slot;
        let lowest_permissible_slot = self.lowest_permissible_slot;
        // Reject any attestations that are too old.
        if slot < lowest_permissible_slot {
            return Err(Error::SlotTooLow {
                slot,
                lowest_permissible_slot,
            });
        }
        let lock_timer =
            metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_MAPS_WRITE_LOCK);
        drop(lock_timer);
        let outcome = if let Some(map) = self.maps.get_mut(&slot) {
            map.insert(attestation)
        } else {
            let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_CREATE_MAP);
            // To avoid re-allocations, try and determine a rough initial capacity for the new item
            // by obtaining the mean size of all items in earlier epoch.
            let (count, sum) = self
                .maps
                .iter()
                // Only include epochs that are less than the given slot in the average. This should
                // generally avoid including recent epochs that are still "filling up".
                .filter(|(map_slot, _item)| **map_slot < slot)
                .map(|(_slot, map)| map.len())
                .fold((0, 0), |(count, sum), len| (count + 1, sum + len));
            // Use the mainnet default committee size if we can't determine an average.
            let initial_capacity = sum.checked_div(count).unwrap_or(128);
            let mut item = AggregatedAttestationMap::new(initial_capacity);
            let outcome = item.insert(attestation);
            self.maps.insert(slot, item);
            outcome
        };
        self.prune(slot);
        outcome
    }
pub fn insert ( & mut self , attestation : & Attestation < E > ) -> Result < InsertOutcome , Error > { let _timer = metrics :: start_timer ( & metrics :: ATTESTATION_PROCESSING_AGG_POOL_INSERT ) ; let slot = attestation . data . slot ; let lowest_permissible_slot = self . lowest_permissible_slot ; // Reject any attestations that are too old. if slot < lowest_permissible_slot { return Err ( Error :: SlotTooLow { slot , lowest_permissible_slot , } ) ; } let lock_timer = metrics :: start_timer ( & metrics :: ATTESTATION_PROCESSING_AGG_POOL_MAPS_WRITE_LOCK ) ; drop ( lock_timer ) ; let outcome = if let Some ( map ) = self . maps . get_mut ( & slot ) { map . insert ( attestation ) } else { let _timer = metrics :: start_timer ( & metrics :: ATTESTATION_PROCESSING_AGG_POOL_CREATE_MAP ) ; // To avoid re-allocations, try and determine a rough initial capacity for the new item // by obtaining the mean size of all items in earlier epoch. let ( count , sum ) = self . maps . iter ( ) // Only include epochs that are less than the given slot in the average. This should // generally avoid including recent epochs that are still "filling up". . filter ( | ( map_slot , _item ) | * * map_slot < slot ) . map ( | ( _slot , map ) | map . len ( ) ) . fold ( ( 0 , 0 ) , | ( count , sum ) , len | ( count + 1 , sum + len ) ) ; // Use the mainnet default committee size if we can't determine an average. let initial_capacity = sum . checked_div ( count ) . unwrap_or ( 128 ) ; let mut item = AggregatedAttestationMap :: new ( initial_capacity ) ; let outcome = item . insert ( attestation ) ; self . maps . insert ( slot , item ) ; outcome } ; self . prune ( slot ) ; outcome }
Insert an attestation into `self`, aggregating it into the pool.
Insert an attestation into ` self ` aggregating it into the pool .
&mut self
attestation
&Attestation<E>