mirror of
https://github.com/tendermint/tendermint.git
synced 2026-10-01 12:15:45 +00:00
rpc: replace Amino with new JSON encoder (#4968)
Migrates the `rpc` package to use new JSON encoder in #4955. Branched off of that PR. Tests pass, but I haven't done any manual testing beyond that. This should be handled as part of broader 0.34 testing.
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
amino "github.com/tendermint/go-amino"
|
||||
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
var cdc = amino.NewCodec()
|
||||
|
||||
func init() {
|
||||
types.RegisterEvidences(cdc)
|
||||
}
|
||||
+4
-11
@@ -8,9 +8,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
amino "github.com/tendermint/go-amino"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
@@ -138,11 +137,8 @@ func NewWithClient(remote, wsEndpoint string, client *http.Client) (*HTTP, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cdc := rc.Codec()
|
||||
ctypes.RegisterAmino(cdc)
|
||||
rc.SetCodec(cdc)
|
||||
|
||||
wsEvents, err := newWSEvents(cdc, remote, wsEndpoint)
|
||||
wsEvents, err := newWSEvents(remote, wsEndpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -479,7 +475,6 @@ var errNotRunning = errors.New("client is not running. Use .Start() method to st
|
||||
// WSEvents is a wrapper around WSClient, which implements EventsClient.
|
||||
type WSEvents struct {
|
||||
service.BaseService
|
||||
cdc *amino.Codec
|
||||
remote string
|
||||
endpoint string
|
||||
ws *jsonrpcclient.WSClient
|
||||
@@ -488,9 +483,8 @@ type WSEvents struct {
|
||||
subscriptions map[string]chan ctypes.ResultEvent // query -> chan
|
||||
}
|
||||
|
||||
func newWSEvents(cdc *amino.Codec, remote, endpoint string) (*WSEvents, error) {
|
||||
func newWSEvents(remote, endpoint string) (*WSEvents, error) {
|
||||
w := &WSEvents{
|
||||
cdc: cdc,
|
||||
endpoint: endpoint,
|
||||
remote: remote,
|
||||
subscriptions: make(map[string]chan ctypes.ResultEvent),
|
||||
@@ -505,7 +499,6 @@ func newWSEvents(cdc *amino.Codec, remote, endpoint string) (*WSEvents, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w.ws.SetCodec(w.cdc)
|
||||
w.ws.SetLogger(w.Logger)
|
||||
|
||||
return w, nil
|
||||
@@ -645,7 +638,7 @@ func (w *WSEvents) eventListener() {
|
||||
}
|
||||
|
||||
result := new(ctypes.ResultEvent)
|
||||
err := w.cdc.UnmarshalJSON(resp.Result, result)
|
||||
err := tmjson.Unmarshal(resp.Result, result)
|
||||
if err != nil {
|
||||
w.Logger.Error("failed to unmarshal response", "err", err)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user