Skip to content

Commit

Permalink
fix: add string trim for PrivValidatorListenAddr string (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeseung-bae authored Mar 19, 2024
1 parent c6e5b1f commit e1be3c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
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

0 comments on commit e1be3c4

Please sign in to comment.