Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add string trim for PrivValidatorListenAddr string #768

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cmd/ostracon/commands/show_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package commands

import (
"fmt"
"strings"

"github.com/Finschia/ostracon/node"
"github.com/Finschia/ostracon/types"
"github.com/spf13/cobra"

cfg "github.com/Finschia/ostracon/config"
tmjson "github.com/Finschia/ostracon/libs/json"
tmos "github.com/Finschia/ostracon/libs/os"
"github.com/Finschia/ostracon/node"
"github.com/Finschia/ostracon/privval"
"github.com/Finschia/ostracon/types"
)

// ShowValidatorCmd adds capabilities for showing the validator info.
Expand All @@ -24,9 +25,9 @@ var ShowValidatorCmd = &cobra.Command{
PreRun: deprecateSnakeCase,
}

func showValidator(cmd *cobra.Command, args []string, config *cfg.Config) error {
func showValidator(_ *cobra.Command, _ []string, config *cfg.Config) error {
var pv types.PrivValidator
if config.PrivValidatorListenAddr != "" {
if strings.TrimSpace(config.PrivValidatorListenAddr) != "" {
chainID, err := loadChainID(config)
if err != nil {
return err
Expand Down
7 changes: 3 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net"
"net/http"
_ "net/http/pprof" // nolint: gosec // securely exposed on separate, optional port
"strings"
"time"

Expand Down Expand Up @@ -53,8 +54,6 @@ import (
tmtime "github.com/Finschia/ostracon/types/time"
"github.com/Finschia/ostracon/version"

_ "net/http/pprof" // nolint: gosec // securely exposed on separate, optional port

_ "github.com/lib/pq" // provide the psql db driver
)

Expand Down Expand Up @@ -124,7 +123,7 @@ func NewOstraconNode(config *cfg.Config, logger log.Logger) (*Node, error) {
}

var privKey types.PrivValidator
if config.PrivValidatorListenAddr == "" {
if strings.TrimSpace(config.PrivValidatorListenAddr) == "" {
privKey = privval.LoadFilePV(
config.PrivValidatorKeyFile(),
config.PrivValidatorStateFile())
Expand Down Expand Up @@ -792,7 +791,7 @@ func NewNode(config *cfg.Config,

// If an address is provided, listen on the socket for a connection from an
// external signing process.
if config.PrivValidatorListenAddr != "" {
if strings.TrimSpace(config.PrivValidatorListenAddr) != "" {
// FIXME: we should start services inside OnStart
privValidator, err = CreateAndStartPrivValidatorSocketClient(config, genDoc.ChainID, logger)
if err != nil {
Expand Down
Loading