rpc/server: move to services/rpcsrv
`server` is not a good package name and it's an internal service, so it can be just about anywhere.
This commit is contained in:
parent
7118b4f4ea
commit
43a59adbd0
24 changed files with 25 additions and 25 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -50,7 +50,7 @@ testdata/
|
||||||
!pkg/compiler/testdata
|
!pkg/compiler/testdata
|
||||||
!pkg/config/testdata
|
!pkg/config/testdata
|
||||||
!pkg/consensus/testdata
|
!pkg/consensus/testdata
|
||||||
!pkg/rpc/server/testdata
|
!pkg/services/rpcsrv/testdata
|
||||||
!pkg/services/notary/testdata
|
!pkg/services/notary/testdata
|
||||||
!pkg/services/oracle/testdata
|
!pkg/services/oracle/testdata
|
||||||
!pkg/smartcontract/testdata
|
!pkg/smartcontract/testdata
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"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/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network"
|
"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/smartcontract/trigger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
"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 is a blockchain instance (can be empty).
|
||||||
Chain *core.Blockchain
|
Chain *core.Blockchain
|
||||||
// RPC is an RPC server to query (can be empty).
|
// 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 is a network server (can be empty).
|
||||||
NetSrv *network.Server
|
NetSrv *network.Server
|
||||||
// Out contains command output.
|
// Out contains command output.
|
||||||
|
@ -120,7 +120,7 @@ func (w *ConcurrentBuffer) Reset() {
|
||||||
w.buf.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"
|
configPath := "../config/protocol.unit_testnet.single.yml"
|
||||||
cfg, err := config.LoadFile(configPath)
|
cfg, err := config.LoadFile(configPath)
|
||||||
require.NoError(t, err, "could not load config")
|
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)
|
netSrv.AddExtensibleHPService(cons, consensus.Category, cons.OnPayload, cons.OnTransaction)
|
||||||
go netSrv.Start(make(chan error, 1))
|
go netSrv.Start(make(chan error, 1))
|
||||||
errCh := make(chan error, 2)
|
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()
|
rpcServer.Start()
|
||||||
|
|
||||||
return chain, &rpcServer, netSrv
|
return chain, &rpcServer, netSrv
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network"
|
"github.com/nspcc-dev/neo-go/pkg/network"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/metrics"
|
"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/notary"
|
||||||
"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/stateroot"
|
"github.com/nspcc-dev/neo-go/pkg/services/stateroot"
|
||||||
|
@ -505,7 +505,7 @@ func startServer(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
errChan := make(chan error)
|
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)
|
serv.AddService(&rpcServer)
|
||||||
|
|
||||||
go serv.Start(errChan)
|
go serv.Start(errChan)
|
||||||
|
@ -532,7 +532,7 @@ Main:
|
||||||
case syscall.SIGHUP:
|
case syscall.SIGHUP:
|
||||||
log.Info("SIGHUP received, restarting rpc-server")
|
log.Info("SIGHUP received, restarting rpc-server")
|
||||||
rpcServer.Shutdown()
|
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.
|
serv.AddService(&rpcServer) // Replaces old one by service name.
|
||||||
if !cfg.ApplicationConfiguration.RPC.StartWhenSynchronized || serv.IsInSync() {
|
if !cfg.ApplicationConfiguration.RPC.StartWhenSynchronized || serv.IsInSync() {
|
||||||
rpcServer.Start()
|
rpcServer.Start()
|
||||||
|
|
|
@ -19,7 +19,7 @@ const (
|
||||||
// basicChainPrefix is a prefix used to store Basic chain .acc file for tests.
|
// 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
|
// It is also used to retrieve smart contracts that should be deployed to
|
||||||
// Basic chain.
|
// Basic chain.
|
||||||
basicChainPrefix = "../rpc/server/testdata/"
|
basicChainPrefix = "../services/rpcsrv/testdata/"
|
||||||
// bcPersistInterval is the time period Blockchain persists changes to the
|
// bcPersistInterval is the time period Blockchain persists changes to the
|
||||||
// underlying storage.
|
// underlying storage.
|
||||||
bcPersistInterval = time.Second
|
bcPersistInterval = time.Second
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"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/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"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"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/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/request"
|
"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/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -45,7 +45,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
|
"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"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"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"
|
||||||
"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/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -25,7 +25,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
notaryPath = "../../services/notary/testdata/notary1.json"
|
notaryPath = "../notary/testdata/notary1.json"
|
||||||
notaryPass = "one"
|
notaryPass = "one"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ func getUnitTestChain(t testing.TB, enableOracle bool, enableNotary bool, disabl
|
||||||
if enableOracle {
|
if enableOracle {
|
||||||
cfg.ApplicationConfiguration.Oracle.Enabled = true
|
cfg.ApplicationConfiguration.Oracle.Enabled = true
|
||||||
cfg.ApplicationConfiguration.Oracle.UnlockWallet = config.Wallet{
|
cfg.ApplicationConfiguration.Oracle.UnlockWallet = config.Wallet{
|
||||||
Path: "../../services/oracle/testdata/oracle1.json",
|
Path: "../oracle/testdata/oracle1.json",
|
||||||
Password: "one",
|
Password: "one",
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -37,7 +37,7 @@ import (
|
||||||
"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/response"
|
"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"
|
||||||
"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"
|
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/smartcontract/trigger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
|
@ -1,4 +1,4 @@
|
||||||
package server
|
package rpcsrv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
Loading…
Reference in a new issue