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