pub fn produce_unaggregated_attestation(
        &self,
        slot: Slot,
        index: CommitteeIndex,
    ) -> Result<Attestation<T::EthSpec>, Error> {
        // Note: we're taking a lock on the head. The work involved here should be trivial enough
        // that the lock should not be held for long.
        let head = self
            .canonical_head
            .try_read_for(HEAD_LOCK_TIMEOUT)
            .ok_or(Error::CanonicalHeadLockTimeout)?;

        if slot >= head.beacon_block.slot() {
            self.produce_unaggregated_attestation_for_block(
                slot,
                index,
                head.beacon_block_root,
                Cow::Borrowed(&head.beacon_state),
                head.beacon_state_root(),
            )
        } else {
            // We disallow producing attestations *prior* to the current head since such an
            // attestation would require loading a `BeaconState` from disk. Loading `BeaconState`
            // from disk is very resource intensive and proposes a DoS risk from validator clients.
            //
            // Although we generally allow validator clients to do things that might harm us (i.e.,
            // we trust them), sometimes we need to protect the BN from accidental errors which
            // could cause it significant harm.
            //
            // This case is particularity harmful since the HTTP API can effectively call this
            // function an unlimited amount of times. If `n` validators all happen to call it at
            // the same time, we're going to load `n` states (and tree hash caches) into memory all
            // at once. With `n >= 10` we're looking at hundreds of MB or GBs of RAM.
            Err(Error::AttestingPriorToHead {
                head_slot: head.beacon_block.slot(),
                request_slot: slot,
            })
        }
    }
/// Produce an unaggregated `Attestation` that is valid for the given `slot` and `index`.
///
/// The produced `Attestation` will not be valid until it has been signed by exactly one
/// validator that is in the committee for `slot` and `index` in the canonical chain.
///
/// Always attests to the canonical chain.


Always attests to the canonical chain.
Always attests to the canonical chain .
pub fn produce_unaggregated_attestation(
        &self,
        slot: Slot,
        index: CommitteeIndex,
    ) -> Result<Attestation<T::EthSpec>, Error> {
        // Note: we're taking a lock on the head. The work involved here should be trivial enough
        // that the lock should not be held for long.
        let head = self
            .canonical_head
            .try_read_for(HEAD_LOCK_TIMEOUT)
            .ok_or(Error::CanonicalHeadLockTimeout)?;
        if slot >= head.beacon_block.slot() {
            self.produce_unaggregated_attestation_for_block(
                slot,
                index,
                head.beacon_block_root,
                Cow::Borrowed(&head.beacon_state),
                head.beacon_state_root(),
            )
        } else {
            // We disallow producing attestations *prior* to the current head since such an
            // attestation would require loading a `BeaconState` from disk. Loading `BeaconState`
            // from disk is very resource intensive and proposes a DoS risk from validator clients.
            //
            // Although we generally allow validator clients to do things that might harm us (i.e.,
            // we trust them), sometimes we need to protect the BN from accidental errors which
            // could cause it significant harm.
            //
            // This case is particularity harmful since the HTTP API can effectively call this
            // function an unlimited amount of times. If `n` validators all happen to call it at
            // the same time, we're going to load `n` states (and tree hash caches) into memory all
            // at once. With `n >= 10` we're looking at hundreds of MB or GBs of RAM.
            Err(Error::AttestingPriorToHead {
                head_slot: head.beacon_block.slot(),
                request_slot: slot,
            })
        }
    }
pub fn produce_unaggregated_attestation ( & self , slot : Slot , index : CommitteeIndex , ) -> Result < Attestation < T :: EthSpec > , Error > { // Note: we're taking a lock on the head. The work involved here should be trivial enough // that the lock should not be held for long. let head = self . canonical_head . try_read_for ( HEAD_LOCK_TIMEOUT ) . ok_or ( Error :: CanonicalHeadLockTimeout ) ? ; if slot >= head . beacon_block . slot ( ) { self . produce_unaggregated_attestation_for_block ( slot , index , head . beacon_block_root , Cow :: Borrowed ( & head . beacon_state ) , head . beacon_state_root ( ) , ) } else { // We disallow producing attestations *prior* to the current head since such an // attestation would require loading a `BeaconState` from disk. Loading `BeaconState` // from disk is very resource intensive and proposes a DoS risk from validator clients. // // Although we generally allow validator clients to do things that might harm us (i.e., // we trust them), sometimes we need to protect the BN from accidental errors which // could cause it significant harm. // // This case is particularity harmful since the HTTP API can effectively call this // function an unlimited amount of times. If `n` validators all happen to call it at // the same time, we're going to load `n` states (and tree hash caches) into memory all // at once. With `n >= 10` we're looking at hundreds of MB or GBs of RAM. Err ( Error :: AttestingPriorToHead { head_slot : head . beacon_block . slot ( ) , request_slot : slot , } ) } }
Produce an unaggregated `Attestation` that is valid for the given `slot` and `index`.
Produce an unaggregated ` Attestation ` that is valid for the given ` slot ` and ` index ` .
&self
slot
Slot
index
CommitteeIndex