pub fn insert(&mut self, a: &Attestation<E>) -> Result<InsertOutcome, Error> {
        let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_CORE_INSERT);

        let set_bits = a
            .aggregation_bits
            .iter()
            .enumerate()
            .filter(|(_i, bit)| *bit)
            .map(|(i, _bit)| i)
            .collect::<Vec<_>>();

        let committee_index = set_bits
            .first()
            .copied()
            .ok_or(Error::NoAggregationBitsSet)?;

        if set_bits.len() > 1 {
            return Err(Error::MoreThanOneAggregationBitSet(set_bits.len()));
        }

        let attestation_data_root = a.data.tree_hash_root();

        if let Some(existing_attestation) = self.map.get_mut(&attestation_data_root) {
            if existing_attestation
                .aggregation_bits
                .get(committee_index)
                .map_err(|_| Error::InconsistentBitfieldLengths)?
            {
                Ok(InsertOutcome::SignatureAlreadyKnown { committee_index })
            } else {
                let _timer =
                    metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_AGGREGATION);
                existing_attestation.aggregate(a);
                Ok(InsertOutcome::SignatureAggregated { committee_index })
            }
        } else {
            if self.map.len() >= MAX_ATTESTATIONS_PER_SLOT {
                return Err(Error::ReachedMaxAttestationsPerSlot(
                    MAX_ATTESTATIONS_PER_SLOT,
                ));
            }

            self.map.insert(attestation_data_root, a.clone());
            Ok(InsertOutcome::NewAttestationData { committee_index })
        }
    }
/// Insert an attestation into `self`, aggregating it into the pool.
///
/// The given attestation (`a`) must only have one signature.
Insert an attestation into `self`, aggregating it into the pool.
The given attestation (`a`) must only have one signature.
Insert an attestation into ` self ` aggregating it into the pool . The given attestation ( ` a ` ) must only have one signature .
pub fn insert(&mut self, a: &Attestation<E>) -> Result<InsertOutcome, Error> {
        let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_CORE_INSERT);
        let set_bits = a
            .aggregation_bits
            .iter()
            .enumerate()
            .filter(|(_i, bit)| *bit)
            .map(|(i, _bit)| i)
            .collect::<Vec<_>>();
        let committee_index = set_bits
            .first()
            .copied()
            .ok_or(Error::NoAggregationBitsSet)?;
        if set_bits.len() > 1 {
            return Err(Error::MoreThanOneAggregationBitSet(set_bits.len()));
        }
        let attestation_data_root = a.data.tree_hash_root();
        if let Some(existing_attestation) = self.map.get_mut(&attestation_data_root) {
            if existing_attestation
                .aggregation_bits
                .get(committee_index)
                .map_err(|_| Error::InconsistentBitfieldLengths)?
            {
                Ok(InsertOutcome::SignatureAlreadyKnown { committee_index })
            } else {
                let _timer =
                    metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_AGGREGATION);
                existing_attestation.aggregate(a);
                Ok(InsertOutcome::SignatureAggregated { committee_index })
            }
        } else {
            if self.map.len() >= MAX_ATTESTATIONS_PER_SLOT {
                return Err(Error::ReachedMaxAttestationsPerSlot(
                    MAX_ATTESTATIONS_PER_SLOT,
                ));
            }
            self.map.insert(attestation_data_root, a.clone());
            Ok(InsertOutcome::NewAttestationData { committee_index })
        }
    }
pub fn insert ( & mut self , a : & Attestation < E > ) -> Result < InsertOutcome , Error > { let _timer = metrics :: start_timer ( & metrics :: ATTESTATION_PROCESSING_AGG_POOL_CORE_INSERT ) ; let set_bits = a . aggregation_bits . iter ( ) . enumerate ( ) . filter ( | ( _i , bit ) | * bit ) . map ( | ( i , _bit ) | i ) . collect :: < Vec < _ > > ( ) ; let committee_index = set_bits . first ( ) . copied ( ) . ok_or ( Error :: NoAggregationBitsSet ) ? ; if set_bits . len ( ) > 1 { return Err ( Error :: MoreThanOneAggregationBitSet ( set_bits . len ( ) ) ) ; } let attestation_data_root = a . data . tree_hash_root ( ) ; if let Some ( existing_attestation ) = self . map . get_mut ( & attestation_data_root ) { if existing_attestation . aggregation_bits . get ( committee_index ) . map_err ( | _ | Error :: InconsistentBitfieldLengths ) ? { Ok ( InsertOutcome :: SignatureAlreadyKnown { committee_index } ) } else { let _timer = metrics :: start_timer ( & metrics :: ATTESTATION_PROCESSING_AGG_POOL_AGGREGATION ) ; existing_attestation . aggregate ( a ) ; Ok ( InsertOutcome :: SignatureAggregated { committee_index } ) } } else { if self . map . len ( ) >= MAX_ATTESTATIONS_PER_SLOT { return Err ( Error :: ReachedMaxAttestationsPerSlot ( MAX_ATTESTATIONS_PER_SLOT , ) ) ; } self . map . insert ( attestation_data_root , a . clone ( ) ) ; Ok ( InsertOutcome :: NewAttestationData { committee_index } ) } }
Insert an attestation into `self`, aggregating it into the pool.
Insert an attestation into ` self ` aggregating it into the pool .
&mut self
a
&Attestation<E>