Skip to content

Commit e1be3c4

Browse files
authored
fix: add string trim for PrivValidatorListenAddr string (#768)
1 parent c6e5b1f commit e1be3c4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cmd/ostracon/commands/show_validator.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package commands
22

33
import (
44
"fmt"
5+
"strings"
56

6-
"github.com/Finschia/ostracon/node"
7-
"github.com/Finschia/ostracon/types"
87
"github.com/spf13/cobra"
98

109
cfg "github.com/Finschia/ostracon/config"
1110
tmjson "github.com/Finschia/ostracon/libs/json"
1211
tmos "github.com/Finschia/ostracon/libs/os"
12+
"github.com/Finschia/ostracon/node"
1313
"github.com/Finschia/ostracon/privval"
14+
"github.com/Finschia/ostracon/types"
1415
)
1516

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

27-
func showValidator(cmd *cobra.Command, args []string, config *cfg.Config) error {
28+
func showValidator(_ *cobra.Command, _ []string, config *cfg.Config) error {
2829
var pv types.PrivValidator
29-
if config.PrivValidatorListenAddr != "" {
30+
if strings.TrimSpace(config.PrivValidatorListenAddr) != "" {
3031
chainID, err := loadChainID(config)
3132
if err != nil {
3233
return err

node/node.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net"
99
"net/http"
10+
_ "net/http/pprof" // nolint: gosec // securely exposed on separate, optional port
1011
"strings"
1112
"time"
1213

@@ -53,8 +54,6 @@ import (
5354
tmtime "github.com/Finschia/ostracon/types/time"
5455
"github.com/Finschia/ostracon/version"
5556

56-
_ "net/http/pprof" // nolint: gosec // securely exposed on separate, optional port
57-
5857
_ "github.com/lib/pq" // provide the psql db driver
5958
)
6059

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

126125
var privKey types.PrivValidator
127-
if config.PrivValidatorListenAddr == "" {
126+
if strings.TrimSpace(config.PrivValidatorListenAddr) == "" {
128127
privKey = privval.LoadFilePV(
129128
config.PrivValidatorKeyFile(),
130129
config.PrivValidatorStateFile())
@@ -792,7 +791,7 @@ func NewNode(config *cfg.Config,
792791

793792
// If an address is provided, listen on the socket for a connection from an
794793
// external signing process.
795-
if config.PrivValidatorListenAddr != "" {
794+
if strings.TrimSpace(config.PrivValidatorListenAddr) != "" {
796795
// FIXME: we should start services inside OnStart
797796
privValidator, err = CreateAndStartPrivValidatorSocketClient(config, genDoc.ChainID, logger)
798797
if err != nil {

0 commit comments

Comments
 (0)