@@ -36,25 +36,25 @@ var log = logrus.WithField("prefix", "node")
36
36
// the entire lifecycle of services attached to it participating in
37
37
// Ethereum Serenity.
38
38
type ValidatorClient struct {
39
- ctx * cli.Context
39
+ cliCtx * cli.Context
40
40
services * shared.ServiceRegistry // Lifecycle and service store.
41
41
lock sync.RWMutex
42
42
stop chan struct {} // Channel to wait for termination notifications.
43
43
}
44
44
45
45
// NewValidatorClient creates a new, Ethereum Serenity validator client.
46
- func NewValidatorClient (ctx * cli.Context ) (* ValidatorClient , error ) {
46
+ func NewValidatorClient (cliCtx * cli.Context ) (* ValidatorClient , error ) {
47
47
if err := tracing .Setup (
48
48
"validator" , // service name
49
- ctx .String (cmd .TracingProcessNameFlag .Name ),
50
- ctx .String (cmd .TracingEndpointFlag .Name ),
51
- ctx .Float64 (cmd .TraceSampleFractionFlag .Name ),
52
- ctx .Bool (cmd .EnableTracingFlag .Name ),
49
+ cliCtx .String (cmd .TracingProcessNameFlag .Name ),
50
+ cliCtx .String (cmd .TracingEndpointFlag .Name ),
51
+ cliCtx .Float64 (cmd .TraceSampleFractionFlag .Name ),
52
+ cliCtx .Bool (cmd .EnableTracingFlag .Name ),
53
53
); err != nil {
54
54
return nil , err
55
55
}
56
56
57
- verbosity := ctx .String (cmd .VerbosityFlag .Name )
57
+ verbosity := cliCtx .String (cmd .VerbosityFlag .Name )
58
58
level , err := logrus .ParseLevel (verbosity )
59
59
if err != nil {
60
60
return nil , err
@@ -63,19 +63,19 @@ func NewValidatorClient(ctx *cli.Context) (*ValidatorClient, error) {
63
63
64
64
registry := shared .NewServiceRegistry ()
65
65
ValidatorClient := & ValidatorClient {
66
- ctx : ctx ,
66
+ cliCtx : cliCtx ,
67
67
services : registry ,
68
68
stop : make (chan struct {}),
69
69
}
70
70
71
- if ctx .IsSet (cmd .ChainConfigFileFlag .Name ) {
72
- chainConfigFileName := ctx .String (cmd .ChainConfigFileFlag .Name )
71
+ if cliCtx .IsSet (cmd .ChainConfigFileFlag .Name ) {
72
+ chainConfigFileName := cliCtx .String (cmd .ChainConfigFileFlag .Name )
73
73
params .LoadChainConfigFile (chainConfigFileName )
74
74
}
75
75
76
- featureconfig .ConfigureValidator (ctx )
76
+ featureconfig .ConfigureValidator (cliCtx )
77
77
78
- keyManager , err := selectKeyManager (ctx )
78
+ keyManager , err := selectKeyManager (cliCtx )
79
79
if err != nil {
80
80
return nil , err
81
81
}
@@ -94,9 +94,9 @@ func NewValidatorClient(ctx *cli.Context) (*ValidatorClient, error) {
94
94
}
95
95
}
96
96
97
- clearFlag := ctx .Bool (cmd .ClearDB .Name )
98
- forceClearFlag := ctx .Bool (cmd .ForceClearDB .Name )
99
- dataDir := ctx .String (cmd .DataDirFlag .Name )
97
+ clearFlag := cliCtx .Bool (cmd .ClearDB .Name )
98
+ forceClearFlag := cliCtx .Bool (cmd .ForceClearDB .Name )
99
+ dataDir := cliCtx .String (cmd .DataDirFlag .Name )
100
100
if clearFlag || forceClearFlag {
101
101
pubkeys , err := keyManager .FetchValidatingKeys ()
102
102
if err != nil {
@@ -111,11 +111,11 @@ func NewValidatorClient(ctx *cli.Context) (*ValidatorClient, error) {
111
111
}
112
112
log .WithField ("databasePath" , dataDir ).Info ("Checking DB" )
113
113
114
- if err := ValidatorClient .registerPrometheusService (ctx ); err != nil {
114
+ if err := ValidatorClient .registerPrometheusService (); err != nil {
115
115
return nil , err
116
116
}
117
117
118
- if err := ValidatorClient .registerClientService (ctx , keyManager ); err != nil {
118
+ if err := ValidatorClient .registerClientService (keyManager ); err != nil {
119
119
return nil , err
120
120
}
121
121
@@ -141,7 +141,7 @@ func (s *ValidatorClient) Start() {
141
141
defer signal .Stop (sigc )
142
142
<- sigc
143
143
log .Info ("Got interrupt, shutting down..." )
144
- debug .Exit (s .ctx ) // Ensure trace and CPU profile data are flushed.
144
+ debug .Exit (s .cliCtx ) // Ensure trace and CPU profile data are flushed.
145
145
go s .Close ()
146
146
for i := 10 ; i > 0 ; i -- {
147
147
<- sigc
@@ -167,24 +167,24 @@ func (s *ValidatorClient) Close() {
167
167
close (s .stop )
168
168
}
169
169
170
- func (s * ValidatorClient ) registerPrometheusService (ctx * cli. Context ) error {
170
+ func (s * ValidatorClient ) registerPrometheusService () error {
171
171
service := prometheus .NewPrometheusService (
172
- fmt .Sprintf (":%d" , ctx .Int64 (flags .MonitoringPortFlag .Name )),
172
+ fmt .Sprintf (":%d" , s . cliCtx .Int64 (flags .MonitoringPortFlag .Name )),
173
173
s .services ,
174
174
)
175
175
logrus .AddHook (prometheus .NewLogrusCollector ())
176
176
return s .services .RegisterService (service )
177
177
}
178
178
179
- func (s * ValidatorClient ) registerClientService (ctx * cli. Context , keyManager keymanager.KeyManager ) error {
180
- endpoint := ctx .String (flags .BeaconRPCProviderFlag .Name )
181
- dataDir := ctx .String (cmd .DataDirFlag .Name )
182
- logValidatorBalances := ! ctx .Bool (flags .DisablePenaltyRewardLogFlag .Name )
183
- emitAccountMetrics := ctx .Bool (flags .AccountMetricsFlag .Name )
184
- cert := ctx .String (flags .CertFlag .Name )
185
- graffiti := ctx .String (flags .GraffitiFlag .Name )
186
- maxCallRecvMsgSize := ctx .Int (cmd .GrpcMaxCallRecvMsgSizeFlag .Name )
187
- grpcRetries := ctx .Uint (flags .GrpcRetriesFlag .Name )
179
+ func (s * ValidatorClient ) registerClientService (keyManager keymanager.KeyManager ) error {
180
+ endpoint := s . cliCtx .String (flags .BeaconRPCProviderFlag .Name )
181
+ dataDir := s . cliCtx .String (cmd .DataDirFlag .Name )
182
+ logValidatorBalances := ! s . cliCtx .Bool (flags .DisablePenaltyRewardLogFlag .Name )
183
+ emitAccountMetrics := s . cliCtx .Bool (flags .AccountMetricsFlag .Name )
184
+ cert := s . cliCtx .String (flags .CertFlag .Name )
185
+ graffiti := s . cliCtx .String (flags .GraffitiFlag .Name )
186
+ maxCallRecvMsgSize := s . cliCtx .Int (cmd .GrpcMaxCallRecvMsgSizeFlag .Name )
187
+ grpcRetries := s . cliCtx .Uint (flags .GrpcRetriesFlag .Name )
188
188
v , err := client .NewValidatorService (context .Background (), & client.Config {
189
189
Endpoint : endpoint ,
190
190
DataDir : dataDir ,
@@ -195,7 +195,7 @@ func (s *ValidatorClient) registerClientService(ctx *cli.Context, keyManager key
195
195
GraffitiFlag : graffiti ,
196
196
GrpcMaxCallRecvMsgSizeFlag : maxCallRecvMsgSize ,
197
197
GrpcRetriesFlag : grpcRetries ,
198
- GrpcHeadersFlag : ctx .String (flags .GrpcHeadersFlag .Name ),
198
+ GrpcHeadersFlag : s . cliCtx .String (flags .GrpcHeadersFlag .Name ),
199
199
})
200
200
if err != nil {
201
201
return errors .Wrap (err , "could not initialize client service" )
0 commit comments