/
options.go
154 lines (133 loc) · 3.78 KB
/
options.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package sync
import (
"github.com/prysmaticlabs/prysm/v4/async/event"
blockfeed "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed/block"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed/operation"
statefeed "github.com/prysmaticlabs/prysm/v4/beacon-chain/core/feed/state"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/db"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/execution"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/attestations"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/blstoexec"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/slashings"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/synccommittee"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/voluntaryexits"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/startup"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/state/stategen"
)
type Option func(s *Service) error
func WithAttestationNotifier(notifier operation.Notifier) Option {
return func(s *Service) error {
s.cfg.attestationNotifier = notifier
return nil
}
}
func WithP2P(p2p p2p.P2P) Option {
return func(s *Service) error {
s.cfg.p2p = p2p
return nil
}
}
func WithDatabase(db db.NoHeadAccessDatabase) Option {
return func(s *Service) error {
s.cfg.beaconDB = db
return nil
}
}
func WithAttestationPool(attPool attestations.Pool) Option {
return func(s *Service) error {
s.cfg.attPool = attPool
return nil
}
}
func WithExitPool(exitPool voluntaryexits.PoolManager) Option {
return func(s *Service) error {
s.cfg.exitPool = exitPool
return nil
}
}
func WithSlashingPool(slashingPool slashings.PoolManager) Option {
return func(s *Service) error {
s.cfg.slashingPool = slashingPool
return nil
}
}
func WithSyncCommsPool(syncCommsPool synccommittee.Pool) Option {
return func(s *Service) error {
s.cfg.syncCommsPool = syncCommsPool
return nil
}
}
func WithBlsToExecPool(blsToExecPool blstoexec.PoolManager) Option {
return func(s *Service) error {
s.cfg.blsToExecPool = blsToExecPool
return nil
}
}
func WithChainService(chain blockchainService) Option {
return func(s *Service) error {
s.cfg.chain = chain
return nil
}
}
func WithInitialSync(initialSync Checker) Option {
return func(s *Service) error {
s.cfg.initialSync = initialSync
return nil
}
}
func WithBlockNotifier(blockNotifier blockfeed.Notifier) Option {
return func(s *Service) error {
s.cfg.blockNotifier = blockNotifier
return nil
}
}
func WithOperationNotifier(operationNotifier operation.Notifier) Option {
return func(s *Service) error {
s.cfg.operationNotifier = operationNotifier
return nil
}
}
func WithStateGen(stateGen *stategen.State) Option {
return func(s *Service) error {
s.cfg.stateGen = stateGen
return nil
}
}
func WithSlasherAttestationsFeed(slasherAttestationsFeed *event.Feed) Option {
return func(s *Service) error {
s.cfg.slasherAttestationsFeed = slasherAttestationsFeed
return nil
}
}
func WithSlasherBlockHeadersFeed(slasherBlockHeadersFeed *event.Feed) Option {
return func(s *Service) error {
s.cfg.slasherBlockHeadersFeed = slasherBlockHeadersFeed
return nil
}
}
func WithPayloadReconstructor(r execution.PayloadReconstructor) Option {
return func(s *Service) error {
s.cfg.executionPayloadReconstructor = r
return nil
}
}
func WithClockWaiter(cw startup.ClockWaiter) Option {
return func(s *Service) error {
s.clockWaiter = cw
return nil
}
}
func WithInitialSyncComplete(c chan struct{}) Option {
return func(s *Service) error {
s.initialSyncComplete = c
return nil
}
}
// WithStateNotifier to notify an event feed of state processing.
func WithStateNotifier(n statefeed.Notifier) Option {
return func(s *Service) error {
s.cfg.stateNotifier = n
return nil
}
}