github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/operations/slashings/types.go (about) 1 package slashings 2 3 import ( 4 "context" 5 "sync" 6 7 types "github.com/prysmaticlabs/eth2-types" 8 iface "github.com/prysmaticlabs/prysm/beacon-chain/state/interface" 9 ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1" 10 ) 11 12 // PoolManager maintains a pool of pending and recently included attester and proposer slashings. 13 // This pool is used by proposers to insert data into new blocks. 14 type PoolManager interface { 15 PendingAttesterSlashings(ctx context.Context, state iface.ReadOnlyBeaconState, noLimit bool) []*ethpb.AttesterSlashing 16 PendingProposerSlashings(ctx context.Context, state iface.ReadOnlyBeaconState, noLimit bool) []*ethpb.ProposerSlashing 17 InsertAttesterSlashing( 18 ctx context.Context, 19 state iface.ReadOnlyBeaconState, 20 slashing *ethpb.AttesterSlashing, 21 ) error 22 InsertProposerSlashing( 23 ctx context.Context, 24 state iface.BeaconState, 25 slashing *ethpb.ProposerSlashing, 26 ) error 27 MarkIncludedAttesterSlashing(as *ethpb.AttesterSlashing) 28 MarkIncludedProposerSlashing(ps *ethpb.ProposerSlashing) 29 } 30 31 // Pool is a concrete implementation of PoolManager. 32 type Pool struct { 33 lock sync.RWMutex 34 pendingProposerSlashing []*ethpb.ProposerSlashing 35 pendingAttesterSlashing []*PendingAttesterSlashing 36 included map[types.ValidatorIndex]bool 37 } 38 39 // PendingAttesterSlashing represents an attester slashing in the operation pool. 40 // Allows for easy binary searching of included validator indexes. 41 type PendingAttesterSlashing struct { 42 attesterSlashing *ethpb.AttesterSlashing 43 validatorToSlash types.ValidatorIndex 44 }