Skip to content

Commit bbb35f5

Browse files
authored
Merge pull request #2839 from nspcc-dev/port-string
config: use string type for Port
2 parents 81d7557 + 3ce1fc4 commit bbb35f5

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

pkg/config/basic_service.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package config
22

33
import (
44
"net"
5-
"strconv"
65
)
76

87
// BasicService is used as a simple base for node services like Pprof, RPC or
@@ -12,7 +11,7 @@ type BasicService struct {
1211
// Deprecated: please, use Addresses section instead. This field will be removed later.
1312
Address *string `yaml:"Address,omitempty"`
1413
// Deprecated: please, use Addresses section instead. This field will be removed later.
15-
Port *uint16 `yaml:"Port,omitempty"`
14+
Port *string `yaml:"Port,omitempty"`
1615
// Addresses holds the list of bind addresses in the form of "address:port".
1716
Addresses []string `yaml:"Addresses"`
1817
}
@@ -25,15 +24,15 @@ func (s BasicService) GetAddresses() []string {
2524
if s.Address != nil || s.Port != nil { //nolint:staticcheck // SA1019: s.Address is deprecated
2625
var (
2726
addr string
28-
port uint16
27+
port string
2928
)
3029
if s.Address != nil { //nolint:staticcheck // SA1019: s.Address is deprecated
3130
addr = *s.Address //nolint:staticcheck // SA1019: s.Address is deprecated
3231
}
3332
if s.Port != nil { //nolint:staticcheck // SA1019: s.Port is deprecated
3433
port = *s.Port //nolint:staticcheck // SA1019: s.Port is deprecated
3534
}
36-
addrs = append(addrs, net.JoinHostPort(addr, strconv.FormatUint(uint64(port), 10)))
35+
addrs = append(addrs, net.JoinHostPort(addr, port))
3736
}
3837
return addrs
3938
}

pkg/config/basic_service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
func TestBasicService_GetAddresses(t *testing.T) {
1010
addr := "1.2.3.4"
11-
port := uint16(1234)
11+
port := "1234"
1212
s := BasicService{
1313
Enabled: false,
1414
Address: &addr,

pkg/config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package config
33
import (
44
"fmt"
55
"os"
6+
"time"
67

78
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
89
"gopkg.in/yaml.v3"
@@ -66,8 +67,8 @@ func LoadFile(configPath string) (Config, error) {
6667
config := Config{
6768
ApplicationConfiguration: ApplicationConfiguration{
6869
P2P: P2P{
69-
PingInterval: 30,
70-
PingTimeout: 30,
70+
PingInterval: 30 * time.Second,
71+
PingTimeout: 90 * time.Second,
7172
},
7273
RPC: RPC{
7374
MaxIteratorResultItems: DefaultMaxIteratorResultItems,

pkg/config/rpc_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ MaxGasInvoke: 15
2020
err := yaml.Unmarshal([]byte(data), &cfg)
2121
require.NoError(t, err)
2222
require.True(t, cfg.Enabled)
23-
require.Equal(t, uint16(10332), *cfg.Port)
23+
require.Equal(t, "10332", *cfg.Port)
2424
}

0 commit comments

Comments
 (0)