diff --git a/cli/server/server_test.go b/cli/server/server_test.go index b55d5b600..f3f8c107c 100644 --- a/cli/server/server_test.go +++ b/cli/server/server_test.go @@ -10,7 +10,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/config" "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" - "github.com/nspcc-dev/neo-go/pkg/rpc" "github.com/stretchr/testify/require" "github.com/urfave/cli" "go.uber.org/zap" @@ -303,7 +302,7 @@ func TestConfigureAddresses(t *testing.T) { t.Run("custom RPC address", func(t *testing.T) { cfg := &config.ApplicationConfiguration{ Address: defaultAddress, - RPC: rpc.Config{ + RPC: config.RPC{ Address: customAddress, }, } diff --git a/pkg/config/application_config.go b/pkg/config/application_config.go index 0a8cb6435..cbf7be3d1 100644 --- a/pkg/config/application_config.go +++ b/pkg/config/application_config.go @@ -2,7 +2,6 @@ package config import ( "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" - "github.com/nspcc-dev/neo-go/pkg/rpc" ) // ApplicationConfiguration config specific to the node. @@ -22,7 +21,7 @@ type ApplicationConfiguration struct { Prometheus BasicService `yaml:"Prometheus"` ProtoTickInterval int64 `yaml:"ProtoTickInterval"` Relay bool `yaml:"Relay"` - RPC rpc.Config `yaml:"RPC"` + RPC RPC `yaml:"RPC"` UnlockWallet Wallet `yaml:"UnlockWallet"` Oracle OracleConfiguration `yaml:"Oracle"` P2PNotary P2PNotary `yaml:"P2PNotary"` diff --git a/pkg/config/config.go b/pkg/config/config.go index be64e5a5f..b2dc05e27 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -5,7 +5,6 @@ import ( "os" "github.com/nspcc-dev/neo-go/pkg/config/netmode" - "github.com/nspcc-dev/neo-go/pkg/rpc" "gopkg.in/yaml.v3" ) @@ -58,7 +57,7 @@ func LoadFile(configPath string) (Config, error) { ApplicationConfiguration: ApplicationConfiguration{ PingInterval: 30, PingTimeout: 90, - RPC: rpc.Config{ + RPC: RPC{ MaxIteratorResultItems: DefaultMaxIteratorResultItems, MaxFindResultItems: 100, MaxNEP11Tokens: 100, diff --git a/pkg/rpc/rpc_config.go b/pkg/config/rpc_config.go similarity index 84% rename from pkg/rpc/rpc_config.go rename to pkg/config/rpc_config.go index 1e3a3f1d0..09cb3bc25 100644 --- a/pkg/rpc/rpc_config.go +++ b/pkg/config/rpc_config.go @@ -1,12 +1,12 @@ -package rpc +package config import ( "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" ) type ( - // Config is an RPC service configuration information. - Config struct { + // RPC is an RPC service configuration information. + RPC struct { Address string `yaml:"Address"` Enabled bool `yaml:"Enabled"` EnableCORSWorkaround bool `yaml:"EnableCORSWorkaround"` @@ -22,11 +22,11 @@ type ( SessionBackedByMPT bool `yaml:"SessionBackedByMPT"` SessionPoolSize int `yaml:"SessionPoolSize"` StartWhenSynchronized bool `yaml:"StartWhenSynchronized"` - TLSConfig TLSConfig `yaml:"TLSConfig"` + TLSConfig TLS `yaml:"TLSConfig"` } - // TLSConfig describes SSL/TLS configuration. - TLSConfig struct { + // TLS describes SSL/TLS configuration. + TLS struct { Address string `yaml:"Address"` CertFile string `yaml:"CertFile"` Enabled bool `yaml:"Enabled"` diff --git a/pkg/services/rpcsrv/server.go b/pkg/services/rpcsrv/server.go index c500ff7ec..a2504e4cb 100644 --- a/pkg/services/rpcsrv/server.go +++ b/pkg/services/rpcsrv/server.go @@ -20,6 +20,7 @@ import ( "github.com/google/uuid" "github.com/gorilla/websocket" + "github.com/nspcc-dev/neo-go/pkg/config" "github.com/nspcc-dev/neo-go/pkg/config/limits" "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/core" @@ -43,7 +44,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/neorpc/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/network" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc" "github.com/nspcc-dev/neo-go/pkg/services/oracle" "github.com/nspcc-dev/neo-go/pkg/services/oracle/broadcaster" "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params" @@ -62,7 +62,7 @@ type ( Server struct { *http.Server chain blockchainer.Blockchainer - config rpc.Config + config config.RPC // wsReadLimit represents web-socket message limit for a receiving side. wsReadLimit int64 network netmode.Magic @@ -197,7 +197,7 @@ var invalidBlockHeightError = func(index int, height int) *neorpc.Error { var upgrader = websocket.Upgrader{} // New creates a new Server struct. -func New(chain blockchainer.Blockchainer, conf rpc.Config, coreServer *network.Server, +func New(chain blockchainer.Blockchainer, conf config.RPC, coreServer *network.Server, orc *oracle.Oracle, log *zap.Logger, errChan chan error) Server { httpServer := &http.Server{ Addr: conf.Address + ":" + strconv.FormatUint(uint64(conf.Port), 10),