github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/operations/attestations/pool.go (about)

     1  package attestations
     2  
     3  import (
     4  	"context"
     5  
     6  	types "github.com/prysmaticlabs/eth2-types"
     7  	"github.com/prysmaticlabs/prysm/beacon-chain/operations/attestations/kv"
     8  	ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
     9  )
    10  
    11  // Pool defines the necessary methods for Prysm attestations pool to serve
    12  // fork choice and validators. In the current design, aggregated attestations
    13  // are used by proposer actor. Unaggregated attestations are used by
    14  // aggregator actor.
    15  type Pool interface {
    16  	// For Aggregated attestations
    17  	AggregateUnaggregatedAttestations(ctx context.Context) error
    18  	AggregateUnaggregatedAttestationsBySlotIndex(ctx context.Context, slot types.Slot, committeeIndex types.CommitteeIndex) error
    19  	SaveAggregatedAttestation(att *ethpb.Attestation) error
    20  	SaveAggregatedAttestations(atts []*ethpb.Attestation) error
    21  	AggregatedAttestations() []*ethpb.Attestation
    22  	AggregatedAttestationsBySlotIndex(ctx context.Context, slot types.Slot, committeeIndex types.CommitteeIndex) []*ethpb.Attestation
    23  	DeleteAggregatedAttestation(att *ethpb.Attestation) error
    24  	HasAggregatedAttestation(att *ethpb.Attestation) (bool, error)
    25  	AggregatedAttestationCount() int
    26  	// For unaggregated attestations.
    27  	SaveUnaggregatedAttestation(att *ethpb.Attestation) error
    28  	SaveUnaggregatedAttestations(atts []*ethpb.Attestation) error
    29  	UnaggregatedAttestations() ([]*ethpb.Attestation, error)
    30  	UnaggregatedAttestationsBySlotIndex(ctx context.Context, slot types.Slot, committeeIndex types.CommitteeIndex) []*ethpb.Attestation
    31  	DeleteUnaggregatedAttestation(att *ethpb.Attestation) error
    32  	DeleteSeenUnaggregatedAttestations() (int, error)
    33  	UnaggregatedAttestationCount() int
    34  	// For attestations that were included in the block.
    35  	SaveBlockAttestation(att *ethpb.Attestation) error
    36  	SaveBlockAttestations(atts []*ethpb.Attestation) error
    37  	BlockAttestations() []*ethpb.Attestation
    38  	DeleteBlockAttestation(att *ethpb.Attestation) error
    39  	// For attestations to be passed to fork choice.
    40  	SaveForkchoiceAttestation(att *ethpb.Attestation) error
    41  	SaveForkchoiceAttestations(atts []*ethpb.Attestation) error
    42  	ForkchoiceAttestations() []*ethpb.Attestation
    43  	DeleteForkchoiceAttestation(att *ethpb.Attestation) error
    44  	ForkchoiceAttestationCount() int
    45  }
    46  
    47  // NewPool initializes a new attestation pool.
    48  func NewPool() *kv.AttCaches {
    49  	return kv.NewAttCaches()
    50  }