diff --git a/.gitignore b/.gitignore index 88843343e..fbc04a091 100644 --- a/.gitignore +++ b/.gitignore @@ -50,7 +50,7 @@ testdata/ !pkg/compiler/testdata !pkg/config/testdata !pkg/consensus/testdata -!pkg/rpc/server/testdata +!pkg/services/rpcsrv/testdata !pkg/services/notary/testdata !pkg/services/oracle/testdata !pkg/smartcontract/testdata diff --git a/cli/executor_test.go b/cli/executor_test.go index 6f69a6881..93d2f9843 100644 --- a/cli/executor_test.go +++ b/cli/executor_test.go @@ -20,7 +20,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/network" - "github.com/nspcc-dev/neo-go/pkg/rpc/server" + "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" @@ -56,7 +56,7 @@ type executor struct { // Chain is a blockchain instance (can be empty). Chain *core.Blockchain // RPC is an RPC server to query (can be empty). - RPC *server.Server + RPC *rpcsrv.Server // NetSrv is a network server (can be empty). NetSrv *network.Server // Out contains command output. @@ -120,7 +120,7 @@ func (w *ConcurrentBuffer) Reset() { w.buf.Reset() } -func newTestChain(t *testing.T, f func(*config.Config), run bool) (*core.Blockchain, *server.Server, *network.Server) { +func newTestChain(t *testing.T, f func(*config.Config), run bool) (*core.Blockchain, *rpcsrv.Server, *network.Server) { configPath := "../config/protocol.unit_testnet.single.yml" cfg, err := config.LoadFile(configPath) require.NoError(t, err, "could not load config") @@ -154,7 +154,7 @@ func newTestChain(t *testing.T, f func(*config.Config), run bool) (*core.Blockch netSrv.AddExtensibleHPService(cons, consensus.Category, cons.OnPayload, cons.OnTransaction) go netSrv.Start(make(chan error, 1)) errCh := make(chan error, 2) - rpcServer := server.New(chain, cfg.ApplicationConfiguration.RPC, netSrv, nil, logger, errCh) + rpcServer := rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, netSrv, nil, logger, errCh) rpcServer.Start() return chain, &rpcServer, netSrv diff --git a/cli/server/server.go b/cli/server/server.go index 93cde7568..64246094d 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -22,7 +22,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/network" "github.com/nspcc-dev/neo-go/pkg/network/metrics" - "github.com/nspcc-dev/neo-go/pkg/rpc/server" + "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv" "github.com/nspcc-dev/neo-go/pkg/services/notary" "github.com/nspcc-dev/neo-go/pkg/services/oracle" "github.com/nspcc-dev/neo-go/pkg/services/stateroot" @@ -505,7 +505,7 @@ func startServer(ctx *cli.Context) error { return cli.NewExitError(err, 1) } errChan := make(chan error) - rpcServer := server.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan) + rpcServer := rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan) serv.AddService(&rpcServer) go serv.Start(errChan) @@ -532,7 +532,7 @@ Main: case syscall.SIGHUP: log.Info("SIGHUP received, restarting rpc-server") rpcServer.Shutdown() - rpcServer = server.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan) + rpcServer = rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan) serv.AddService(&rpcServer) // Replaces old one by service name. if !cfg.ApplicationConfiguration.RPC.StartWhenSynchronized || serv.IsInSync() { rpcServer.Start() diff --git a/pkg/core/basic_chain_test.go b/pkg/core/basic_chain_test.go index aac129172..0bbac46dc 100644 --- a/pkg/core/basic_chain_test.go +++ b/pkg/core/basic_chain_test.go @@ -19,7 +19,7 @@ const ( // basicChainPrefix is a prefix used to store Basic chain .acc file for tests. // It is also used to retrieve smart contracts that should be deployed to // Basic chain. - basicChainPrefix = "../rpc/server/testdata/" + basicChainPrefix = "../services/rpcsrv/testdata/" // bcPersistInterval is the time period Blockchain persists changes to the // underlying storage. bcPersistInterval = time.Second diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index c50c2b271..ae1f89863 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -28,7 +28,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" - "github.com/nspcc-dev/neo-go/pkg/rpc/server/params" + "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/nef" diff --git a/pkg/rpc/client/wsclient_test.go b/pkg/rpc/client/wsclient_test.go index b4d93fec7..2b6bde70f 100644 --- a/pkg/rpc/client/wsclient_test.go +++ b/pkg/rpc/client/wsclient_test.go @@ -18,7 +18,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/rpc/request" - "github.com/nspcc-dev/neo-go/pkg/rpc/server/params" + "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/stretchr/testify/require" "go.uber.org/atomic" diff --git a/pkg/rpc/server/client_test.go b/pkg/services/rpcsrv/client_test.go similarity index 99% rename from pkg/rpc/server/client_test.go rename to pkg/services/rpcsrv/client_test.go index 40df78ee8..33f672cff 100644 --- a/pkg/rpc/server/client_test.go +++ b/pkg/services/rpcsrv/client_test.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "bytes" diff --git a/pkg/rpc/server/error.go b/pkg/services/rpcsrv/error.go similarity index 99% rename from pkg/rpc/server/error.go rename to pkg/services/rpcsrv/error.go index 8c5223224..102a4f07f 100644 --- a/pkg/rpc/server/error.go +++ b/pkg/services/rpcsrv/error.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "net/http" diff --git a/pkg/rpc/server/params/param.go b/pkg/services/rpcsrv/params/param.go similarity index 100% rename from pkg/rpc/server/params/param.go rename to pkg/services/rpcsrv/params/param.go diff --git a/pkg/rpc/server/params/param_test.go b/pkg/services/rpcsrv/params/param_test.go similarity index 100% rename from pkg/rpc/server/params/param_test.go rename to pkg/services/rpcsrv/params/param_test.go diff --git a/pkg/rpc/server/params/params.go b/pkg/services/rpcsrv/params/params.go similarity index 100% rename from pkg/rpc/server/params/params.go rename to pkg/services/rpcsrv/params/params.go diff --git a/pkg/rpc/server/params/txBuilder.go b/pkg/services/rpcsrv/params/txBuilder.go similarity index 100% rename from pkg/rpc/server/params/txBuilder.go rename to pkg/services/rpcsrv/params/txBuilder.go diff --git a/pkg/rpc/server/params/tx_builder_test.go b/pkg/services/rpcsrv/params/tx_builder_test.go similarity index 100% rename from pkg/rpc/server/params/tx_builder_test.go rename to pkg/services/rpcsrv/params/tx_builder_test.go diff --git a/pkg/rpc/server/params/types.go b/pkg/services/rpcsrv/params/types.go similarity index 100% rename from pkg/rpc/server/params/types.go rename to pkg/services/rpcsrv/params/types.go diff --git a/pkg/rpc/server/params/types_test.go b/pkg/services/rpcsrv/params/types_test.go similarity index 100% rename from pkg/rpc/server/params/types_test.go rename to pkg/services/rpcsrv/params/types_test.go diff --git a/pkg/rpc/server/prometheus.go b/pkg/services/rpcsrv/prometheus.go similarity index 97% rename from pkg/rpc/server/prometheus.go rename to pkg/services/rpcsrv/prometheus.go index 60b1351bf..8de59c1e7 100644 --- a/pkg/rpc/server/prometheus.go +++ b/pkg/services/rpcsrv/prometheus.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "fmt" diff --git a/pkg/rpc/server/server.go b/pkg/services/rpcsrv/server.go similarity index 99% rename from pkg/rpc/server/server.go rename to pkg/services/rpcsrv/server.go index 28ccfa246..73244a556 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/services/rpcsrv/server.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "bytes" @@ -45,7 +45,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" - "github.com/nspcc-dev/neo-go/pkg/rpc/server/params" + "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params" "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/smartcontract/callflag" diff --git a/pkg/rpc/server/server_helper_test.go b/pkg/services/rpcsrv/server_helper_test.go similarity index 97% rename from pkg/rpc/server/server_helper_test.go rename to pkg/services/rpcsrv/server_helper_test.go index 64e08c7ad..7dbad237e 100644 --- a/pkg/rpc/server/server_helper_test.go +++ b/pkg/services/rpcsrv/server_helper_test.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "fmt" @@ -25,7 +25,7 @@ import ( ) const ( - notaryPath = "../../services/notary/testdata/notary1.json" + notaryPath = "../notary/testdata/notary1.json" notaryPass = "one" ) @@ -50,7 +50,7 @@ func getUnitTestChain(t testing.TB, enableOracle bool, enableNotary bool, disabl if enableOracle { cfg.ApplicationConfiguration.Oracle.Enabled = true cfg.ApplicationConfiguration.Oracle.UnlockWallet = config.Wallet{ - Path: "../../services/oracle/testdata/oracle1.json", + Path: "../oracle/testdata/oracle1.json", Password: "one", } } diff --git a/pkg/rpc/server/server_test.go b/pkg/services/rpcsrv/server_test.go similarity index 99% rename from pkg/rpc/server/server_test.go rename to pkg/services/rpcsrv/server_test.go index 4190a1b18..dedce792b 100644 --- a/pkg/rpc/server/server_test.go +++ b/pkg/services/rpcsrv/server_test.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "bytes" @@ -37,7 +37,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" - "github.com/nspcc-dev/neo-go/pkg/rpc/server/params" + "github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/params" rpc2 "github.com/nspcc-dev/neo-go/pkg/services/oracle/broadcaster" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" diff --git a/pkg/rpc/server/subscription.go b/pkg/services/rpcsrv/subscription.go similarity index 99% rename from pkg/rpc/server/subscription.go rename to pkg/services/rpcsrv/subscription.go index ef9d6ea66..3c4964913 100644 --- a/pkg/rpc/server/subscription.go +++ b/pkg/services/rpcsrv/subscription.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "github.com/gorilla/websocket" diff --git a/pkg/rpc/server/subscription_test.go b/pkg/services/rpcsrv/subscription_test.go similarity index 99% rename from pkg/rpc/server/subscription_test.go rename to pkg/services/rpcsrv/subscription_test.go index bd90cc10c..0a2d2e82e 100644 --- a/pkg/rpc/server/subscription_test.go +++ b/pkg/services/rpcsrv/subscription_test.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "encoding/json" diff --git a/pkg/rpc/server/testdata/testblocks.acc b/pkg/services/rpcsrv/testdata/testblocks.acc similarity index 100% rename from pkg/rpc/server/testdata/testblocks.acc rename to pkg/services/rpcsrv/testdata/testblocks.acc diff --git a/pkg/rpc/server/tokens.go b/pkg/services/rpcsrv/tokens.go similarity index 98% rename from pkg/rpc/server/tokens.go rename to pkg/services/rpcsrv/tokens.go index 9cfd5cd7a..fab1f905d 100644 --- a/pkg/rpc/server/tokens.go +++ b/pkg/services/rpcsrv/tokens.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" diff --git a/pkg/rpc/server/util.go b/pkg/services/rpcsrv/util.go similarity index 95% rename from pkg/rpc/server/util.go rename to pkg/services/rpcsrv/util.go index bbacc9b2d..9607eef18 100644 --- a/pkg/rpc/server/util.go +++ b/pkg/services/rpcsrv/util.go @@ -1,4 +1,4 @@ -package server +package rpcsrv import ( "errors"