Validator client - Improve readability - NO FUNCTIONAL CHANGE (#13468)

* Improve `NewServiceRegistry` documentation.

* Improve `README.md`.

* Improve readability of `registerValidatorService`.

* Move `log` in `main.go`.

Since `log` is only used in `main.go`.

* Clean Tos.

* `DefaultDataDir`: Use `switch` instead of `if/elif`.

* `ReadPassword`: Remove unused receiver.

* `validator/main.go`: Clean.

* `WarnIfPlatformNotSupported`: Add Mac OSX ARM64.

* `runner.go`: Use idiomatic `err` handling.

* `waitForChainStart`: Avoid `chainStartResponse`mutation.

* `WaitForChainStart`: Reduce cognitive complexity.

* Logs: `powchain` ==> `execution`.
This commit is contained in:
Manu NALEPA
2024-01-15 15:46:54 +01:00
committed by GitHub
parent b585ff77f5
commit 99a8d0bac6
15 changed files with 150 additions and 109 deletions

View File

@@ -103,7 +103,12 @@ func WarnIfPlatformNotSupported(ctx context.Context) {
return
}
if !supported {
log.Warn("This platform is not supported. The following platforms are supported: Linux/AMD64," +
" Linux/ARM64, Mac OS X/AMD64 (10.14+ only), and Windows/AMD64")
log.Warn(`This platform is not supported. The following platforms are supported:
- Linux/AMD64
- Linux/ARM64
- Mac OS X/AMD64 (from 10.14+)
- Mac OS X/ARM64 (from 12.5+)
- Windows/AMD64`,
)
}
}

View File

@@ -31,7 +31,7 @@ type ServiceRegistry struct {
serviceTypes []reflect.Type // keep an ordered slice of registered service types.
}
// NewServiceRegistry starts a registry instance for convenience
// NewServiceRegistry starts a registry instance for convenience.
func NewServiceRegistry() *ServiceRegistry {
return &ServiceRegistry{
services: make(map[reflect.Type]Service),

View File

@@ -35,11 +35,13 @@ var (
log = logrus.WithField("prefix", "tos")
)
// VerifyTosAcceptedOrPrompt check if Tos was accepted before or asks to accept.
// VerifyTosAcceptedOrPrompt checks if Tos was accepted before or asks to accept.
func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
if file.Exists(filepath.Join(ctx.String(cmd.DataDirFlag.Name), acceptTosFilename)) {
tosFilePath := filepath.Join(ctx.String(cmd.DataDirFlag.Name), acceptTosFilename)
if file.Exists(tosFilePath) {
return nil
}
if ctx.Bool(cmd.AcceptTosFlag.Name) {
saveTosAccepted(ctx)
return nil
@@ -49,6 +51,7 @@ func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
if err != nil {
return errors.New(acceptTosPromptErrText)
}
if !strings.EqualFold(input, "accept") {
return errors.New("you have to accept Terms and Conditions in order to continue")
}