mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 13:41:47 +00:00
rpc: move rpc.Config to pkg/config, remove pkg/rpc
Makes no sense keeping it as is and TLS can be reused in the future.
This commit is contained in:
parent
1e0750e3cd
commit
8e70cd3596
5 changed files with 12 additions and 15 deletions
|
@ -10,7 +10,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"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/core/storage/dbconfig"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -303,7 +302,7 @@ func TestConfigureAddresses(t *testing.T) {
|
||||||
t.Run("custom RPC address", func(t *testing.T) {
|
t.Run("custom RPC address", func(t *testing.T) {
|
||||||
cfg := &config.ApplicationConfiguration{
|
cfg := &config.ApplicationConfiguration{
|
||||||
Address: defaultAddress,
|
Address: defaultAddress,
|
||||||
RPC: rpc.Config{
|
RPC: config.RPC{
|
||||||
Address: customAddress,
|
Address: customAddress,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig"
|
"github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ApplicationConfiguration config specific to the node.
|
// ApplicationConfiguration config specific to the node.
|
||||||
|
@ -22,7 +21,7 @@ type ApplicationConfiguration struct {
|
||||||
Prometheus BasicService `yaml:"Prometheus"`
|
Prometheus BasicService `yaml:"Prometheus"`
|
||||||
ProtoTickInterval int64 `yaml:"ProtoTickInterval"`
|
ProtoTickInterval int64 `yaml:"ProtoTickInterval"`
|
||||||
Relay bool `yaml:"Relay"`
|
Relay bool `yaml:"Relay"`
|
||||||
RPC rpc.Config `yaml:"RPC"`
|
RPC RPC `yaml:"RPC"`
|
||||||
UnlockWallet Wallet `yaml:"UnlockWallet"`
|
UnlockWallet Wallet `yaml:"UnlockWallet"`
|
||||||
Oracle OracleConfiguration `yaml:"Oracle"`
|
Oracle OracleConfiguration `yaml:"Oracle"`
|
||||||
P2PNotary P2PNotary `yaml:"P2PNotary"`
|
P2PNotary P2PNotary `yaml:"P2PNotary"`
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ func LoadFile(configPath string) (Config, error) {
|
||||||
ApplicationConfiguration: ApplicationConfiguration{
|
ApplicationConfiguration: ApplicationConfiguration{
|
||||||
PingInterval: 30,
|
PingInterval: 30,
|
||||||
PingTimeout: 90,
|
PingTimeout: 90,
|
||||||
RPC: rpc.Config{
|
RPC: RPC{
|
||||||
MaxIteratorResultItems: DefaultMaxIteratorResultItems,
|
MaxIteratorResultItems: DefaultMaxIteratorResultItems,
|
||||||
MaxFindResultItems: 100,
|
MaxFindResultItems: 100,
|
||||||
MaxNEP11Tokens: 100,
|
MaxNEP11Tokens: 100,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package rpc
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// Config is an RPC service configuration information.
|
// RPC is an RPC service configuration information.
|
||||||
Config struct {
|
RPC struct {
|
||||||
Address string `yaml:"Address"`
|
Address string `yaml:"Address"`
|
||||||
Enabled bool `yaml:"Enabled"`
|
Enabled bool `yaml:"Enabled"`
|
||||||
EnableCORSWorkaround bool `yaml:"EnableCORSWorkaround"`
|
EnableCORSWorkaround bool `yaml:"EnableCORSWorkaround"`
|
||||||
|
@ -22,11 +22,11 @@ type (
|
||||||
SessionBackedByMPT bool `yaml:"SessionBackedByMPT"`
|
SessionBackedByMPT bool `yaml:"SessionBackedByMPT"`
|
||||||
SessionPoolSize int `yaml:"SessionPoolSize"`
|
SessionPoolSize int `yaml:"SessionPoolSize"`
|
||||||
StartWhenSynchronized bool `yaml:"StartWhenSynchronized"`
|
StartWhenSynchronized bool `yaml:"StartWhenSynchronized"`
|
||||||
TLSConfig TLSConfig `yaml:"TLSConfig"`
|
TLSConfig TLS `yaml:"TLSConfig"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TLSConfig describes SSL/TLS configuration.
|
// TLS describes SSL/TLS configuration.
|
||||||
TLSConfig struct {
|
TLS struct {
|
||||||
Address string `yaml:"Address"`
|
Address string `yaml:"Address"`
|
||||||
CertFile string `yaml:"CertFile"`
|
CertFile string `yaml:"CertFile"`
|
||||||
Enabled bool `yaml:"Enabled"`
|
Enabled bool `yaml:"Enabled"`
|
|
@ -20,6 +20,7 @@ import (
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/gorilla/websocket"
|
"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/limits"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core"
|
"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/neorpc/result/subscriptions"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network"
|
"github.com/nspcc-dev/neo-go/pkg/network"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"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"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/services/oracle/broadcaster"
|
"github.com/nspcc-dev/neo-go/pkg/services/oracle/broadcaster"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params"
|
"github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params"
|
||||||
|
@ -62,7 +62,7 @@ type (
|
||||||
Server struct {
|
Server struct {
|
||||||
*http.Server
|
*http.Server
|
||||||
chain blockchainer.Blockchainer
|
chain blockchainer.Blockchainer
|
||||||
config rpc.Config
|
config config.RPC
|
||||||
// wsReadLimit represents web-socket message limit for a receiving side.
|
// wsReadLimit represents web-socket message limit for a receiving side.
|
||||||
wsReadLimit int64
|
wsReadLimit int64
|
||||||
network netmode.Magic
|
network netmode.Magic
|
||||||
|
@ -197,7 +197,7 @@ var invalidBlockHeightError = func(index int, height int) *neorpc.Error {
|
||||||
var upgrader = websocket.Upgrader{}
|
var upgrader = websocket.Upgrader{}
|
||||||
|
|
||||||
// New creates a new Server struct.
|
// 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 {
|
orc *oracle.Oracle, log *zap.Logger, errChan chan error) Server {
|
||||||
httpServer := &http.Server{
|
httpServer := &http.Server{
|
||||||
Addr: conf.Address + ":" + strconv.FormatUint(uint64(conf.Port), 10),
|
Addr: conf.Address + ":" + strconv.FormatUint(uint64(conf.Port), 10),
|
||||||
|
|
Loading…
Reference in a new issue