func (am *attestationMempool) GetMempoolDifference(message *pb.GetAttestationMempoolMessage) ([]primitives.Attestation, error) {
	difference := make([]primitives.Attestation, 0)

	am.attestationsLock.RLock()
	defer am.attestationsLock.RUnlock()

	attestationsInMessage := make(map[chainhash.Hash]struct{})

	for _, mempoolInv := range message.Attestations {
		attestationHash, err := chainhash.NewHash(mempoolInv.AttestationHash)
		if err != nil {
			return nil, err
		}

		attestationsInMessage[*attestationHash] = struct{}{}

		atts, found := am.attestations[*attestationHash]
		if !found {
			// we don't have the attestation
			continue
		} else {
			// we do have the attestation, so figure out which attestations to send
			for _, att := range atts {
				intersect, err := doAttestationsIntersect(att.ParticipationBitfield, &att)
				if err != nil {
					return nil, err
				}

				if !intersect {
					difference = append(difference, att)
				}
			}
		}
	}

	for h, atts := range am.attestations {
		if _, found := attestationsInMessage[h]; !found {
			difference = append(difference, atts...)
		}
	}

	return difference, nil
}
// GetMempoolDifference gets the difference between our mempool and a peer's
GetMempoolDifference gets the difference between our mempool and a peer's
// GetMempoolDifference gets the difference between our mempool and a peer ' s
func (am *attestationMempool) GetMempoolDifference(message *pb.GetAttestationMempoolMessage) ([]primitives.Attestation, error) {
	difference := make([]primitives.Attestation, 0)
	am.attestationsLock.RLock()
	defer am.attestationsLock.RUnlock()
	attestationsInMessage := make(map[chainhash.Hash]struct{})
	for _, mempoolInv := range message.Attestations {
		attestationHash, err := chainhash.NewHash(mempoolInv.AttestationHash)
		if err != nil {
			return nil, err
		}
		attestationsInMessage[*attestationHash] = struct{}{}
		atts, found := am.attestations[*attestationHash]
		if !found {
			continue
		} else {
			for _, att := range atts {
				intersect, err := doAttestationsIntersect(att.ParticipationBitfield, &att)
				if err != nil {
					return nil, err
				}
				if !intersect {
					difference = append(difference, att)
				}
			}
		}
	}
	for h, atts := range am.attestations {
		if _, found := attestationsInMessage[h]; !found {
			difference = append(difference, atts...)
		}
	}
	return difference, nil
}
func ( am * attestationMempool ) GetMempoolDifference ( message * pb . GetAttestationMempoolMessage ) ( [ ] primitives . Attestation , error ) { difference := make ( [ ] primitives . Attestation , 0 ) am . attestationsLock . RLock ( ) defer am . attestationsLock . RUnlock ( ) attestationsInMessage := make ( map [ chainhash . Hash ] struct { } ) for _ , mempoolInv := range message . Attestations { attestationHash , err := chainhash . NewHash ( mempoolInv . AttestationHash ) if err != nil { return nil , err } attestationsInMessage [ * attestationHash ] = struct { } { } atts , found := am . attestations [ * attestationHash ] if ! found { continue } else { for _ , att := range atts { intersect , err := doAttestationsIntersect ( att . ParticipationBitfield , & att ) if err != nil { return nil , err } if ! intersect { difference = append ( difference , att ) } } } } for h , atts := range am . attestations { if _ , found := attestationsInMessage [ h ] ; ! found { difference = append ( difference , atts ... ) } } return difference , nil }
GetMempoolDifference gets the difference between our mempool and a peer's
GetMempoolDifference gets the difference between our mempool and a peer ' s
// we don't have the attestation // we do have the attestation, so figure out which attestations to send