Browse Source

rpc: refactor lib folder (#4836)

Closes https://github.com/tendermint/tendermint/issues/3857

Moves `lib/` folder to `jsonrpc/`.

Renames:

**packages**

`rpc` package -> `jsonrpc` package
`rpcclient` package -> `client` package
`rpcserver` package -> `server` package

**structs and interfaces**

```
JSONRPCClient to Client
JSONRPCRequestBatch to RequestBatch
JSONRPCCaller to Caller
```

**functions**

```
StartHTTPServer to Serve
StartHTTPAndTLSServer to ServeTLS

rpc/jsonrpc/client: rename NewURIClient to NewURI

NewJSONRPCClient to New
NewJSONRPCClientWithHTTPClient to NewWithHTTPClient
NewWSClient to NewWS
```

**misc**

- unexpose `ResponseWriterWrapper`
- remove unused http_params.go
pull/4843/head
Anton Kaliaev 5 years ago
committed by GitHub
parent
commit
a14ff5cb30
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 191 additions and 248 deletions
  1. +18
    -0
      CHANGELOG_PENDING.md
  2. +4
    -4
      Makefile
  3. +1
    -1
      cmd/tendermint/commands/lite.go
  4. +3
    -3
      lite/proxy/proxy.go
  5. +1
    -1
      lite/proxy/wrapper.go
  6. +3
    -3
      lite2/proxy/proxy.go
  7. +2
    -2
      lite2/proxy/routes.go
  8. +1
    -1
      lite2/rpc/client.go
  9. +3
    -3
      node/node.go
  10. +9
    -9
      rpc/client/http/http.go
  11. +1
    -1
      rpc/client/local/local.go
  12. +1
    -1
      rpc/client/mock/client.go
  13. +4
    -4
      rpc/client/rpc_test.go
  14. +1
    -1
      rpc/core/abci.go
  15. +1
    -1
      rpc/core/blocks.go
  16. +1
    -1
      rpc/core/blocks_test.go
  17. +1
    -1
      rpc/core/consensus.go
  18. +1
    -1
      rpc/core/dev.go
  19. +1
    -1
      rpc/core/events.go
  20. +1
    -1
      rpc/core/evidence.go
  21. +1
    -1
      rpc/core/health.go
  22. +1
    -1
      rpc/core/mempool.go
  23. +1
    -1
      rpc/core/net.go
  24. +1
    -1
      rpc/core/net_test.go
  25. +1
    -1
      rpc/core/routes.go
  26. +1
    -1
      rpc/core/status.go
  27. +1
    -1
      rpc/core/tx.go
  28. +1
    -1
      rpc/grpc/api.go
  29. +1
    -1
      rpc/jsonrpc/client/args_test.go
  30. +2
    -2
      rpc/jsonrpc/client/decode.go
  31. +1
    -1
      rpc/jsonrpc/client/encode.go
  32. +34
    -34
      rpc/jsonrpc/client/http_json_client.go
  33. +1
    -1
      rpc/jsonrpc/client/http_json_client_test.go
  34. +4
    -4
      rpc/jsonrpc/client/http_uri_client.go
  35. +2
    -2
      rpc/jsonrpc/client/integration_test.go
  36. +4
    -4
      rpc/jsonrpc/client/ws_client.go
  37. +3
    -3
      rpc/jsonrpc/client/ws_client_test.go
  38. +2
    -2
      rpc/jsonrpc/doc.go
  39. +18
    -18
      rpc/jsonrpc/jsonrpc_test.go
  40. +2
    -2
      rpc/jsonrpc/server/http_json_handler.go
  41. +2
    -2
      rpc/jsonrpc/server/http_json_handler_test.go
  42. +16
    -12
      rpc/jsonrpc/server/http_server.go
  43. +4
    -4
      rpc/jsonrpc/server/http_server_test.go
  44. +15
    -4
      rpc/jsonrpc/server/http_uri_handler.go
  45. +2
    -2
      rpc/jsonrpc/server/parse_test.go
  46. +1
    -1
      rpc/jsonrpc/server/rpc_func.go
  47. +0
    -0
      rpc/jsonrpc/server/test.crt
  48. +0
    -0
      rpc/jsonrpc/server/test.key
  49. +2
    -2
      rpc/jsonrpc/server/ws_handler.go
  50. +2
    -2
      rpc/jsonrpc/server/ws_handler_test.go
  51. +0
    -0
      rpc/jsonrpc/test/data.json
  52. +0
    -0
      rpc/jsonrpc/test/integration_test.sh
  53. +3
    -3
      rpc/jsonrpc/test/main.go
  54. +1
    -1
      rpc/jsonrpc/types/types.go
  55. +1
    -1
      rpc/jsonrpc/types/types_test.go
  56. +0
    -90
      rpc/lib/server/http_params.go
  57. +2
    -2
      rpc/test/helpers.go

+ 18
- 0
CHANGELOG_PENDING.md View File

@ -27,6 +27,24 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- [types] \#4798 Simplify `VerifyCommitTrusting` func + remove extra validation (@melekes) - [types] \#4798 Simplify `VerifyCommitTrusting` func + remove extra validation (@melekes)
- [libs] \#4831 Remove `Bech32` pkg from Tendermint. This pkg now lives in the [cosmos-sdk](https://github.com/cosmos/cosmos-sdk/tree/4173ea5ebad906dd9b45325bed69b9c655504867/types/bech32) - [libs] \#4831 Remove `Bech32` pkg from Tendermint. This pkg now lives in the [cosmos-sdk](https://github.com/cosmos/cosmos-sdk/tree/4173ea5ebad906dd9b45325bed69b9c655504867/types/bech32)
- [node] [\#4832](https://github.com/tendermint/tendermint/pull/4832) `ConfigureRPC` returns an error (@melekes) - [node] [\#4832](https://github.com/tendermint/tendermint/pull/4832) `ConfigureRPC` returns an error (@melekes)
- [rpc] [\#4836](https://github.com/tendermint/tendermint/pull/4836) Overhaul `lib` folder (@melekes)
Move lib/ folder to jsonrpc/.
Rename:
rpc package -> jsonrpc package
rpcclient package -> client package
rpcserver package -> server package
JSONRPCClient to Client
JSONRPCRequestBatch to RequestBatch
JSONRPCCaller to Caller
StartHTTPServer to Serve
StartHTTPAndTLSServer to ServeTLS
NewURIClient to NewURI
NewJSONRPCClient to New
NewJSONRPCClientWithHTTPClient to NewWithHTTPClient
NewWSClient to NewWS
Unexpose ResponseWriterWrapper
Remove unused http_params.go
- Blockchain Protocol - Blockchain Protocol


+ 4
- 4
Makefile View File

@ -135,15 +135,15 @@ gen_certs: clean_certs
certstrap init --common-name "tendermint.com" --passphrase "" certstrap init --common-name "tendermint.com" --passphrase ""
certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase "" certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase ""
certstrap sign "server" --CA "tendermint.com" --passphrase "" certstrap sign "server" --CA "tendermint.com" --passphrase ""
mv out/server.crt rpc/lib/server/test.crt
mv out/server.key rpc/lib/server/test.key
mv out/server.crt rpc/jsonrpc/server/test.crt
mv out/server.key rpc/jsonrpc/server/test.key
rm -rf out rm -rf out
.PHONY: gen_certs .PHONY: gen_certs
# deletes generated certificates # deletes generated certificates
clean_certs: clean_certs:
rm -f rpc/lib/server/test.crt
rm -f rpc/lib/server/test.key
rm -f rpc/jsonrpc/server/test.crt
rm -f rpc/jsonrpc/server/test.key
.PHONY: clean_certs .PHONY: clean_certs
############################################################################### ###############################################################################


+ 1
- 1
cmd/tendermint/commands/lite.go View File

@ -19,7 +19,7 @@ import (
lrpc "github.com/tendermint/tendermint/lite2/rpc" lrpc "github.com/tendermint/tendermint/lite2/rpc"
dbs "github.com/tendermint/tendermint/lite2/store/db" dbs "github.com/tendermint/tendermint/lite2/store/db"
rpchttp "github.com/tendermint/tendermint/rpc/client/http" rpchttp "github.com/tendermint/tendermint/rpc/client/http"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
rpcserver "github.com/tendermint/tendermint/rpc/jsonrpc/server"
) )
// LiteCmd represents the base command when called without any subcommands // LiteCmd represents the base command when called without any subcommands


+ 3
- 3
lite/proxy/proxy.go View File

@ -11,8 +11,8 @@ import (
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
rpcclient "github.com/tendermint/tendermint/rpc/client" rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpcserver "github.com/tendermint/tendermint/rpc/jsonrpc/server"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )
@ -54,7 +54,7 @@ func StartProxy(c rpcclient.Client, listenAddr string, logger log.Logger, maxOpe
if err != nil { if err != nil {
return err return err
} }
return rpcserver.StartHTTPServer(l, mux, logger, config)
return rpcserver.Serve(l, mux, logger, config)
} }
// RPCRoutes just routes everything to the given client, as if it were // RPCRoutes just routes everything to the given client, as if it were


+ 1
- 1
lite/proxy/wrapper.go View File

@ -8,7 +8,7 @@ import (
"github.com/tendermint/tendermint/lite" "github.com/tendermint/tendermint/lite"
rpcclient "github.com/tendermint/tendermint/rpc/client" rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
) )
var _ rpcclient.Client = Wrapper{} var _ rpcclient.Client = Wrapper{}


+ 3
- 3
lite2/proxy/proxy.go View File

@ -12,7 +12,7 @@ import (
tmpubsub "github.com/tendermint/tendermint/libs/pubsub" tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
lrpc "github.com/tendermint/tendermint/lite2/rpc" lrpc "github.com/tendermint/tendermint/lite2/rpc"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
rpcserver "github.com/tendermint/tendermint/rpc/jsonrpc/server"
) )
// A Proxy defines parameters for running an HTTP server proxy. // A Proxy defines parameters for running an HTTP server proxy.
@ -36,7 +36,7 @@ func (p *Proxy) ListenAndServe() error {
} }
p.Listener = listener p.Listener = listener
return rpcserver.StartHTTPServer(
return rpcserver.Serve(
listener, listener,
mux, mux,
p.Logger, p.Logger,
@ -54,7 +54,7 @@ func (p *Proxy) ListenAndServeTLS(certFile, keyFile string) error {
} }
p.Listener = listener p.Listener = listener
return rpcserver.StartHTTPAndTLSServer(
return rpcserver.ServeTLS(
listener, listener,
mux, mux,
certFile, certFile,


+ 2
- 2
lite2/proxy/routes.go View File

@ -4,8 +4,8 @@ import (
"github.com/tendermint/tendermint/libs/bytes" "github.com/tendermint/tendermint/libs/bytes"
lrpc "github.com/tendermint/tendermint/lite2/rpc" lrpc "github.com/tendermint/tendermint/lite2/rpc"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpcserver "github.com/tendermint/tendermint/rpc/jsonrpc/server"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
lite2/rpc/client.go View File

@ -14,7 +14,7 @@ import (
lite "github.com/tendermint/tendermint/lite2" lite "github.com/tendermint/tendermint/lite2"
rpcclient "github.com/tendermint/tendermint/rpc/client" rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 3
- 3
node/node.go View File

@ -39,7 +39,7 @@ import (
rpccore "github.com/tendermint/tendermint/rpc/core" rpccore "github.com/tendermint/tendermint/rpc/core"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
grpccore "github.com/tendermint/tendermint/rpc/grpc" grpccore "github.com/tendermint/tendermint/rpc/grpc"
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
rpcserver "github.com/tendermint/tendermint/rpc/jsonrpc/server"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/state/txindex" "github.com/tendermint/tendermint/state/txindex"
"github.com/tendermint/tendermint/state/txindex/kv" "github.com/tendermint/tendermint/state/txindex/kv"
@ -1044,7 +1044,7 @@ func (n *Node) startRPC() ([]net.Listener, error) {
rootHandler = corsMiddleware.Handler(mux) rootHandler = corsMiddleware.Handler(mux)
} }
if n.config.RPC.IsTLSEnabled() { if n.config.RPC.IsTLSEnabled() {
go rpcserver.StartHTTPAndTLSServer(
go rpcserver.ServeTLS(
listener, listener,
rootHandler, rootHandler,
n.config.RPC.CertFile(), n.config.RPC.CertFile(),
@ -1053,7 +1053,7 @@ func (n *Node) startRPC() ([]net.Listener, error) {
config, config,
) )
} else { } else {
go rpcserver.StartHTTPServer(
go rpcserver.Serve(
listener, listener,
rootHandler, rootHandler,
rpcLogger, rpcLogger,


+ 9
- 9
rpc/client/http/http.go View File

@ -16,7 +16,7 @@ import (
"github.com/tendermint/tendermint/libs/service" "github.com/tendermint/tendermint/libs/service"
rpcclient "github.com/tendermint/tendermint/rpc/client" rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpcclientlib "github.com/tendermint/tendermint/rpc/lib/client"
jsonrpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )
@ -61,7 +61,7 @@ Example:
*/ */
type HTTP struct { type HTTP struct {
remote string remote string
rpc *rpcclientlib.JSONRPCClient
rpc *jsonrpcclient.Client
*baseRPCClient *baseRPCClient
*WSEvents *WSEvents
@ -78,7 +78,7 @@ type HTTP struct {
// batch, but ordering of transactions in the batch cannot be guaranteed in such // batch, but ordering of transactions in the batch cannot be guaranteed in such
// an example. // an example.
type BatchHTTP struct { type BatchHTTP struct {
rpcBatch *rpcclientlib.JSONRPCRequestBatch
rpcBatch *jsonrpcclient.RequestBatch
*baseRPCClient *baseRPCClient
} }
@ -96,7 +96,7 @@ type rpcClient interface {
// baseRPCClient implements the basic RPC method logic without the actual // baseRPCClient implements the basic RPC method logic without the actual
// underlying RPC call functionality, which is provided by `caller`. // underlying RPC call functionality, which is provided by `caller`.
type baseRPCClient struct { type baseRPCClient struct {
caller rpcclientlib.JSONRPCCaller
caller jsonrpcclient.Caller
} }
var _ rpcClient = (*HTTP)(nil) var _ rpcClient = (*HTTP)(nil)
@ -110,7 +110,7 @@ var _ rpcClient = (*baseRPCClient)(nil)
// the websocket path (which always seems to be "/websocket") // the websocket path (which always seems to be "/websocket")
// An error is returned on invalid remote. The function panics when remote is nil. // An error is returned on invalid remote. The function panics when remote is nil.
func New(remote, wsEndpoint string) (*HTTP, error) { func New(remote, wsEndpoint string) (*HTTP, error) {
httpClient, err := rpcclientlib.DefaultHTTPClient(remote)
httpClient, err := jsonrpcclient.DefaultHTTPClient(remote)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -119,7 +119,7 @@ func New(remote, wsEndpoint string) (*HTTP, error) {
// Create timeout enabled http client // Create timeout enabled http client
func NewWithTimeout(remote, wsEndpoint string, timeout uint) (*HTTP, error) { func NewWithTimeout(remote, wsEndpoint string, timeout uint) (*HTTP, error) {
httpClient, err := rpcclientlib.DefaultHTTPClient(remote)
httpClient, err := jsonrpcclient.DefaultHTTPClient(remote)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -134,7 +134,7 @@ func NewWithClient(remote, wsEndpoint string, client *http.Client) (*HTTP, error
panic("nil http.Client provided") panic("nil http.Client provided")
} }
rc, err := rpcclientlib.NewJSONRPCClientWithHTTPClient(remote, client)
rc, err := jsonrpcclient.NewWithHTTPClient(remote, client)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -459,7 +459,7 @@ type WSEvents struct {
cdc *amino.Codec cdc *amino.Codec
remote string remote string
endpoint string endpoint string
ws *rpcclientlib.WSClient
ws *jsonrpcclient.WSClient
mtx sync.RWMutex mtx sync.RWMutex
subscriptions map[string]chan ctypes.ResultEvent // query -> chan subscriptions map[string]chan ctypes.ResultEvent // query -> chan
@ -475,7 +475,7 @@ func newWSEvents(cdc *amino.Codec, remote, endpoint string) (*WSEvents, error) {
w.BaseService = *service.NewBaseService(nil, "WSEvents", w) w.BaseService = *service.NewBaseService(nil, "WSEvents", w)
var err error var err error
w.ws, err = rpcclientlib.NewWSClient(w.remote, w.endpoint, rpcclientlib.OnReconnect(func() {
w.ws, err = jsonrpcclient.NewWS(w.remote, w.endpoint, jsonrpcclient.OnReconnect(func() {
// resubscribe immediately // resubscribe immediately
w.redoSubscriptionsAfter(0 * time.Second) w.redoSubscriptionsAfter(0 * time.Second)
})) }))


+ 1
- 1
rpc/client/local/local.go View File

@ -13,7 +13,7 @@ import (
rpcclient "github.com/tendermint/tendermint/rpc/client" rpcclient "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/core" "github.com/tendermint/tendermint/rpc/core"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
rpc/client/mock/client.go View File

@ -22,7 +22,7 @@ import (
"github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/core" "github.com/tendermint/tendermint/rpc/core"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 4
- 4
rpc/client/rpc_test.go View File

@ -20,7 +20,7 @@ import (
rpchttp "github.com/tendermint/tendermint/rpc/client/http" rpchttp "github.com/tendermint/tendermint/rpc/client/http"
rpclocal "github.com/tendermint/tendermint/rpc/client/local" rpclocal "github.com/tendermint/tendermint/rpc/client/local"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpcclient "github.com/tendermint/tendermint/rpc/lib/client"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
rpctest "github.com/tendermint/tendermint/rpc/test" rpctest "github.com/tendermint/tendermint/rpc/test"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )
@ -62,7 +62,7 @@ func TestNilCustomHTTPClient(t *testing.T) {
_, _ = rpchttp.NewWithClient("http://example.com", "/websocket", nil) _, _ = rpchttp.NewWithClient("http://example.com", "/websocket", nil)
}) })
require.Panics(t, func() { require.Panics(t, func() {
_, _ = rpcclient.NewJSONRPCClientWithHTTPClient("http://example.com", nil)
_, _ = rpcclient.NewWithHTTPClient("http://example.com", nil)
}) })
} }
@ -634,14 +634,14 @@ func TestBatchedJSONRPCCallsCancellation(t *testing.T) {
require.Equal(t, 0, batch.Count()) require.Equal(t, 0, batch.Count())
} }
func TestSendingEmptyJSONRPCRequestBatch(t *testing.T) {
func TestSendingEmptyRequestBatch(t *testing.T) {
c := getHTTPClient() c := getHTTPClient()
batch := c.NewBatch() batch := c.NewBatch()
_, err := batch.Send() _, err := batch.Send()
require.Error(t, err, "sending an empty batch of JSON RPC requests should result in an error") require.Error(t, err, "sending an empty batch of JSON RPC requests should result in an error")
} }
func TestClearingEmptyJSONRPCRequestBatch(t *testing.T) {
func TestClearingEmptyRequestBatch(t *testing.T) {
c := getHTTPClient() c := getHTTPClient()
batch := c.NewBatch() batch := c.NewBatch()
require.Zero(t, batch.Clear(), "clearing an empty batch of JSON RPC requests should result in a 0 result") require.Zero(t, batch.Clear(), "clearing an empty batch of JSON RPC requests should result in a 0 result")


+ 1
- 1
rpc/core/abci.go View File

@ -5,7 +5,7 @@ import (
"github.com/tendermint/tendermint/libs/bytes" "github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
) )
// ABCIQuery queries the application for some information. // ABCIQuery queries the application for some information.


+ 1
- 1
rpc/core/blocks.go View File

@ -5,7 +5,7 @@ import (
tmmath "github.com/tendermint/tendermint/libs/math" tmmath "github.com/tendermint/tendermint/libs/math"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
rpc/core/blocks_test.go View File

@ -11,7 +11,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
rpc/core/consensus.go View File

@ -4,7 +4,7 @@ import (
cm "github.com/tendermint/tendermint/consensus" cm "github.com/tendermint/tendermint/consensus"
tmmath "github.com/tendermint/tendermint/libs/math" tmmath "github.com/tendermint/tendermint/libs/math"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
rpc/core/dev.go View File

@ -5,7 +5,7 @@ import (
"runtime/pprof" "runtime/pprof"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
) )
// UnsafeFlushMempool removes all transactions from the mempool. // UnsafeFlushMempool removes all transactions from the mempool.


+ 1
- 1
rpc/core/events.go View File

@ -7,7 +7,7 @@ import (
tmpubsub "github.com/tendermint/tendermint/libs/pubsub" tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
tmquery "github.com/tendermint/tendermint/libs/pubsub/query" tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
) )
const ( const (


+ 1
- 1
rpc/core/evidence.go View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
rpc/core/health.go View File

@ -2,7 +2,7 @@ package core
import ( import (
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
) )
// Health gets node health. Returns empty result (200 OK) on success, no // Health gets node health. Returns empty result (200 OK) on success, no


+ 1
- 1
rpc/core/mempool.go View File

@ -9,7 +9,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
mempl "github.com/tendermint/tendermint/mempool" mempl "github.com/tendermint/tendermint/mempool"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
rpc/core/net.go View File

@ -6,7 +6,7 @@ import (
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
) )
// NetInfo returns network info. // NetInfo returns network info.


+ 1
- 1
rpc/core/net_test.go View File

@ -9,7 +9,7 @@ import (
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
) )
func TestUnsafeDialSeeds(t *testing.T) { func TestUnsafeDialSeeds(t *testing.T) {


+ 1
- 1
rpc/core/routes.go View File

@ -1,7 +1,7 @@
package core package core
import ( import (
rpc "github.com/tendermint/tendermint/rpc/lib/server"
rpc "github.com/tendermint/tendermint/rpc/jsonrpc/server"
) )
// TODO: better system than "unsafe" prefix // TODO: better system than "unsafe" prefix


+ 1
- 1
rpc/core/status.go View File

@ -7,7 +7,7 @@ import (
tmbytes "github.com/tendermint/tendermint/libs/bytes" tmbytes "github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
rpc/core/tx.go View File

@ -8,7 +8,7 @@ import (
tmmath "github.com/tendermint/tendermint/libs/math" tmmath "github.com/tendermint/tendermint/libs/math"
tmquery "github.com/tendermint/tendermint/libs/pubsub/query" tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"github.com/tendermint/tendermint/state/txindex/null" "github.com/tendermint/tendermint/state/txindex/null"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )


+ 1
- 1
rpc/grpc/api.go View File

@ -5,7 +5,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
core "github.com/tendermint/tendermint/rpc/core" core "github.com/tendermint/tendermint/rpc/core"
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
) )
type broadcastAPI struct { type broadcastAPI struct {


rpc/lib/client/args_test.go → rpc/jsonrpc/client/args_test.go View File


rpc/lib/client/decode.go → rpc/jsonrpc/client/decode.go View File


rpc/lib/client/encode.go → rpc/jsonrpc/client/encode.go View File


rpc/lib/client/http_json_client.go → rpc/jsonrpc/client/http_json_client.go View File


rpc/lib/client/http_json_client_test.go → rpc/jsonrpc/client/http_json_client_test.go View File


rpc/lib/client/http_uri_client.go → rpc/jsonrpc/client/http_uri_client.go View File


rpc/lib/client/integration_test.go → rpc/jsonrpc/client/integration_test.go View File


rpc/lib/client/ws_client.go → rpc/jsonrpc/client/ws_client.go View File


rpc/lib/client/ws_client_test.go → rpc/jsonrpc/client/ws_client_test.go View File


rpc/lib/doc.go → rpc/jsonrpc/doc.go View File


rpc/lib/rpc_test.go → rpc/jsonrpc/jsonrpc_test.go View File


rpc/lib/server/http_json_handler.go → rpc/jsonrpc/server/http_json_handler.go View File


rpc/lib/server/http_json_handler_test.go → rpc/jsonrpc/server/http_json_handler_test.go View File


rpc/lib/server/http_server.go → rpc/jsonrpc/server/http_server.go View File


rpc/lib/server/http_server_test.go → rpc/jsonrpc/server/http_server_test.go View File


rpc/lib/server/http_uri_handler.go → rpc/jsonrpc/server/http_uri_handler.go View File


rpc/lib/server/parse_test.go → rpc/jsonrpc/server/parse_test.go View File


rpc/lib/server/rpc_func.go → rpc/jsonrpc/server/rpc_func.go View File


rpc/lib/server/test.crt → rpc/jsonrpc/server/test.crt View File


rpc/lib/server/test.key → rpc/jsonrpc/server/test.key View File


rpc/lib/server/ws_handler.go → rpc/jsonrpc/server/ws_handler.go View File


rpc/lib/server/ws_handler_test.go → rpc/jsonrpc/server/ws_handler_test.go View File


rpc/lib/test/data.json → rpc/jsonrpc/test/data.json View File


rpc/lib/test/integration_test.sh → rpc/jsonrpc/test/integration_test.sh View File


rpc/lib/test/main.go → rpc/jsonrpc/test/main.go View File


rpc/lib/types/types.go → rpc/jsonrpc/types/types.go View File


rpc/lib/types/types_test.go → rpc/jsonrpc/types/types_test.go View File


+ 0
- 90
rpc/lib/server/http_params.go View File

@ -1,90 +0,0 @@
package rpcserver
import (
"encoding/hex"
"fmt"
"net/http"
"regexp"
"strconv"
)
var (
// Parts of regular expressions
atom = "[A-Z0-9!#$%&'*+\\-/=?^_`{|}~]+"
dotAtom = atom + `(?:\.` + atom + `)*`
domain = `[A-Z0-9.-]+\.[A-Z]{2,4}`
ReInt = regexp.MustCompile(`^-?[0-9]+$`)
ReHex = regexp.MustCompile(`^(?i)[a-f0-9]+$`)
ReEmail = regexp.MustCompile(`^(?i)(` + dotAtom + `)@(` + dotAtom + `)$`)
ReAddress = regexp.MustCompile(`^(?i)[a-z0-9]{25,34}$`)
ReHost = regexp.MustCompile(`^(?i)(` + domain + `)$`)
//RE_ID12 = regexp.MustCompile(`^[a-zA-Z0-9]{12}$`)
)
func GetParam(r *http.Request, param string) string {
s := r.URL.Query().Get(param)
if s == "" {
s = r.FormValue(param)
}
return s
}
func GetParamByteSlice(r *http.Request, param string) ([]byte, error) {
s := GetParam(r, param)
return hex.DecodeString(s)
}
func GetParamInt64(r *http.Request, param string) (int64, error) {
s := GetParam(r, param)
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return 0, fmt.Errorf(param, err.Error())
}
return i, nil
}
func GetParamInt32(r *http.Request, param string) (int32, error) {
s := GetParam(r, param)
i, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return 0, fmt.Errorf(param, err.Error())
}
return int32(i), nil
}
func GetParamUint64(r *http.Request, param string) (uint64, error) {
s := GetParam(r, param)
i, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return 0, fmt.Errorf(param, err.Error())
}
return i, nil
}
func GetParamUint(r *http.Request, param string) (uint, error) {
s := GetParam(r, param)
i, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return 0, fmt.Errorf(param, err.Error())
}
return uint(i), nil
}
func GetParamRegexp(r *http.Request, param string, re *regexp.Regexp) (string, error) {
s := GetParam(r, param)
if !re.MatchString(s) {
return "", fmt.Errorf(param, "did not match regular expression %v", re.String())
}
return s, nil
}
func GetParamFloat64(r *http.Request, param string) (float64, error) {
s := GetParam(r, param)
f, err := strconv.ParseFloat(s, 64)
if err != nil {
return 0, fmt.Errorf(param, err.Error())
}
return f, nil
}

+ 2
- 2
rpc/test/helpers.go View File

@ -19,7 +19,7 @@ import (
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
core_grpc "github.com/tendermint/tendermint/rpc/grpc" core_grpc "github.com/tendermint/tendermint/rpc/grpc"
rpcclient "github.com/tendermint/tendermint/rpc/lib/client"
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
) )
// Options helps with specifying some parameters for our RPC testing for greater // Options helps with specifying some parameters for our RPC testing for greater
@ -37,7 +37,7 @@ var defaultOptions = Options{
func waitForRPC() { func waitForRPC() {
laddr := GetConfig().RPC.ListenAddress laddr := GetConfig().RPC.ListenAddress
client, err := rpcclient.NewJSONRPCClient(laddr)
client, err := rpcclient.New(laddr)
if err != nil { if err != nil {
panic(err) panic(err)
} }


Loading…
Cancel
Save