Fix rpc/lib/...

This commit is contained in:
Jae Kwon
2018-04-05 15:45:11 -07:00
parent e4492afbad
commit 3037b5b7ca
10 changed files with 132 additions and 72 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/pkg/errors"
metrics "github.com/rcrowley/go-metrics"
"github.com/tendermint/go-amino"
types "github.com/tendermint/tendermint/rpc/lib/types"
cmn "github.com/tendermint/tmlibs/common"
)
@ -31,6 +32,7 @@ type WSClient struct {
cmn.BaseService
conn *websocket.Conn
cdc *amino.Codec
Address string // IP:PORT or /path/to/socket
Endpoint string // /websocket/url/endpoint
@ -77,6 +79,7 @@ type WSClient struct {
func NewWSClient(remoteAddr, endpoint string, options ...func(*WSClient)) *WSClient {
addr, dialer := makeHTTPDialer(remoteAddr)
c := &WSClient{
cdc: amino.NewCodec(),
Address: addr,
Dialer: dialer,
Endpoint: endpoint,
@ -206,7 +209,7 @@ func (c *WSClient) Send(ctx context.Context, request types.RPCRequest) error {
// Call the given method. See Send description.
func (c *WSClient) Call(ctx context.Context, method string, params map[string]interface{}) error {
request, err := types.MapToRequest("ws-client", method, params)
request, err := types.MapToRequest(c.cdc, "ws-client", method, params)
if err != nil {
return err
}
@ -216,13 +219,17 @@ func (c *WSClient) Call(ctx context.Context, method string, params map[string]in
// CallWithArrayParams the given method with params in a form of array. See
// Send description.
func (c *WSClient) CallWithArrayParams(ctx context.Context, method string, params []interface{}) error {
request, err := types.ArrayToRequest("ws-client", method, params)
request, err := types.ArrayToRequest(c.cdc, "ws-client", method, params)
if err != nil {
return err
}
return c.Send(ctx, request)
}
func (c *WSClient) Codec() *amino.Codec {
return c.cdc
}
///////////////////////////////////////////////////////////////////////////////
// Private methods