diff --git a/rpc/codec.go b/rpc/codec.go deleted file mode 100644 index 750a5a88e8a6ea672fe635ef41c2f69d2c36274d..0000000000000000000000000000000000000000 --- a/rpc/codec.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 Monax Industries Limited -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package rpc - -import ( - "io" -) - -// Used for rpc request and response data. -type Codec interface { - EncodeBytes(interface{}) ([]byte, error) - Encode(interface{}, io.Writer) error - DecodeBytes(interface{}, []byte) error - DecodeBytesPtr(interface{}, []byte) error - Decode(interface{}, io.Reader) error -} diff --git a/rpc/v0/codec.go b/rpc/v0/codec.go index e32d6fee0abd4fc2b14d08e0868d6493b71bed48..04fab0308e15c0283826315c93d676b5f3c971c0 100644 --- a/rpc/v0/codec.go +++ b/rpc/v0/codec.go @@ -18,9 +18,9 @@ import ( "io" "io/ioutil" - wire "github.com/tendermint/go-wire" - rpc "github.com/eris-ltd/eris-db/rpc" + wire "github.com/tendermint/go-wire" + "reflect" ) // Codec that uses tendermints 'binary' package for JSON. @@ -28,7 +28,7 @@ type TCodec struct { } // Get a new codec. -func NewTCodec() rpc.Codec { +func NewTCodec() Codec { return &TCodec{} } @@ -45,8 +45,6 @@ func (this *TCodec) EncodeBytes(v interface{}) ([]byte, error) { return wire.JSONBytes(v), nil } -// TODO: [ben] implement EncodeBytesPtr ? - // Decode from an io.Reader. func (this *TCodec) Decode(v interface{}, r io.Reader) error { bts, errR := ioutil.ReadAll(r) @@ -61,13 +59,11 @@ func (this *TCodec) Decode(v interface{}, r io.Reader) error { // Decode from a byte array. func (this *TCodec) DecodeBytes(v interface{}, bts []byte) error { var err error - wire.ReadJSON(v, bts, &err) - return err -} - -// Decode from a byte array pointer. -func (this *TCodec) DecodeBytesPtr(v interface{}, bts []byte) error { - var err error - wire.ReadJSONPtr(v, bts, &err) + rv := reflect.ValueOf(v) + if rv.Kind() == reflect.Ptr { + wire.ReadJSONPtr(v, bts, &err) + } else { + wire.ReadJSON(v, bts, &err) + } return err } diff --git a/rpc/v0/json_service_data_test.go b/rpc/v0/codec_test.go similarity index 94% rename from rpc/v0/json_service_data_test.go rename to rpc/v0/codec_test.go index f618b26396f3cb80c374ca1c1192f99752261598..c51eed68a909006ba4865715eddfe402773b501b 100644 --- a/rpc/v0/json_service_data_test.go +++ b/rpc/v0/codec_test.go @@ -18,7 +18,6 @@ import ( "encoding/json" "testing" - "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/txs" "github.com/stretchr/testify/assert" @@ -61,10 +60,10 @@ func TestCallTxJsonFormatCodec(t *testing.T) { param := new(txs.Tx) // Create new request object and unmarshal. - request := &rpc.RPCRequest{} + request := &RPCRequest{} assert.NoError(t, json.Unmarshal(testBroadcastCallTxJsonRequest, request), "Provided JSON test data does not unmarshal to rpc.RPCRequest object.") - assert.NoError(t, codec.DecodeBytesPtr(param, request.Params), + assert.NoError(t, codec.DecodeBytes(param, request.Params), "RPC codec failed to decode params as transaction type.") _, ok := (*param).(*txs.CallTx) assert.True(t, ok, "Type byte 0x02 should unmarshal into CallTx.") diff --git a/rpc/jsonrpc.go b/rpc/v0/json_rpc.go similarity index 86% rename from rpc/jsonrpc.go rename to rpc/v0/json_rpc.go index fc04317a43ebd77faa3850e9f781fedb1e627143..46ca4b06788df04b7da1d1d98f002c678001a41f 100644 --- a/rpc/jsonrpc.go +++ b/rpc/v0/json_rpc.go @@ -12,16 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -package rpc +package v0 import ( "encoding/json" + "io" ) // JSON-RPC 2.0 error codes. const ( - PARSE_ERROR = -32700 INVALID_REQUEST = -32600 + PARSE_ERROR = -32700 METHOD_NOT_FOUND = -32601 INVALID_PARAMS = -32602 INTERNAL_ERROR = -32603 @@ -64,8 +65,26 @@ type ( // Note: Data is currently unused, and the data member may be omitted // Data interface{} `json:"data"` } + + Codec interface { + EncodeBytes(interface{}) ([]byte, error) + Encode(interface{}, io.Writer) error + DecodeBytes(interface{}, []byte) error + Decode(interface{}, io.Reader) error + } ) +// Create a new RPC request. This is the generic struct that is passed to RPC +// methods +func NewRPCRequest(id string, method string, params json.RawMessage) *RPCRequest { + return &RPCRequest{ + JSONRPC: "2.0", + Id: id, + Method: method, + Params: params, + } +} + // NewRPCResponse creates a new response object from a result func NewRPCResponse(id string, res interface{}) RPCResponse { return RPCResponse(&RPCResultResponse{ diff --git a/rpc/v0/json_service.go b/rpc/v0/json_rpc_server.go similarity index 84% rename from rpc/v0/json_service.go rename to rpc/v0/json_rpc_server.go index 05dfb1770fc524c8259bc0448ee60ca723175c4e..9908bb424738485dd5f8579362e285faeee20e05 100644 --- a/rpc/v0/json_service.go +++ b/rpc/v0/json_rpc_server.go @@ -22,7 +22,6 @@ import ( definitions "github.com/eris-ltd/eris-db/definitions" event "github.com/eris-ltd/eris-db/event" - rpc "github.com/eris-ltd/eris-db/rpc" server "github.com/eris-ltd/eris-db/server" ) @@ -65,14 +64,14 @@ func (this *JsonRpcServer) handleFunc(c *gin.Context) { // Used for ErisDb. Implements server.HttpService type ErisDbJsonService struct { - codec rpc.Codec + codec Codec pipe definitions.Pipe eventSubs *event.EventSubscriptions defaultHandlers map[string]RequestHandlerFunc } // Create a new JSON-RPC 2.0 service for erisdb (tendermint). -func NewErisDbJsonService(codec rpc.Codec, pipe definitions.Pipe, +func NewErisDbJsonService(codec Codec, pipe definitions.Pipe, eventSubs *event.EventSubscriptions) server.HttpService { tmhttps := &ErisDbJsonService{codec: codec, pipe: pipe, eventSubs: eventSubs} @@ -91,21 +90,21 @@ func NewErisDbJsonService(codec rpc.Codec, pipe definitions.Pipe, func (this *ErisDbJsonService) Process(r *http.Request, w http.ResponseWriter) { // Create new request object and unmarshal. - req := &rpc.RPCRequest{} + req := &RPCRequest{} decoder := json.NewDecoder(r.Body) errU := decoder.Decode(req) // Error when decoding. if errU != nil { this.writeError("Failed to parse request: "+errU.Error(), "", - rpc.PARSE_ERROR, w) + PARSE_ERROR, w) return } // Wrong protocol version. if req.JSONRPC != "2.0" { this.writeError("Wrong protocol version: "+req.JSONRPC, req.Id, - rpc.INVALID_REQUEST, w) + INVALID_REQUEST, w) return } @@ -119,13 +118,13 @@ func (this *ErisDbJsonService) Process(r *http.Request, w http.ResponseWriter) { this.writeResponse(req.Id, resp, w) } } else { - this.writeError("Method not found: "+mName, req.Id, rpc.METHOD_NOT_FOUND, w) + this.writeError("Method not found: "+mName, req.Id, METHOD_NOT_FOUND, w) } } // Helper for writing error responses. func (this *ErisDbJsonService) writeError(msg, id string, code int, w http.ResponseWriter) { - response := rpc.NewRPCErrorResponse(id, code, msg) + response := NewRPCErrorResponse(id, code, msg) err := this.codec.Encode(response, w) // If there's an error here all bets are off. if err != nil { @@ -137,10 +136,10 @@ func (this *ErisDbJsonService) writeError(msg, id string, code int, w http.Respo // Helper for writing responses. func (this *ErisDbJsonService) writeResponse(id string, result interface{}, w http.ResponseWriter) { - response := rpc.NewRPCResponse(id, result) + response := NewRPCResponse(id, result) err := this.codec.Encode(response, w) if err != nil { - this.writeError("Internal error: "+err.Error(), id, rpc.INTERNAL_ERROR, w) + this.writeError("Internal error: "+err.Error(), id, INTERNAL_ERROR, w) return } w.WriteHeader(200) @@ -149,51 +148,51 @@ func (this *ErisDbJsonService) writeResponse(id string, result interface{}, w ht // *************************************** Events ************************************ // Subscribe to an event. -func (this *ErisDbJsonService) EventSubscribe(request *rpc.RPCRequest, +func (this *ErisDbJsonService) EventSubscribe(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &EventIdParam{} err := json.Unmarshal(request.Params, param) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } eventId := param.EventId subId, errC := this.eventSubs.Add(eventId) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return &event.EventSub{subId}, 0, nil } // Un-subscribe from an event. -func (this *ErisDbJsonService) EventUnsubscribe(request *rpc.RPCRequest, +func (this *ErisDbJsonService) EventUnsubscribe(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &SubIdParam{} err := json.Unmarshal(request.Params, param) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } subId := param.SubId errC := this.pipe.Events().Unsubscribe(subId) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return &event.EventUnsub{true}, 0, nil } // Check subscription event cache for new data. -func (this *ErisDbJsonService) EventPoll(request *rpc.RPCRequest, +func (this *ErisDbJsonService) EventPoll(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &SubIdParam{} err := json.Unmarshal(request.Params, param) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } subId := param.SubId result, errC := this.eventSubs.Poll(subId) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return &event.PollResponse{result}, 0, nil } diff --git a/rpc/v0/json_rpc_server_test.go b/rpc/v0/json_rpc_server_test.go index d123beb39ff01c789c0da3cef7163542e2e121b5..c9de5cd639ee6c6078b667dd7c45c60b135f4a59 100644 --- a/rpc/v0/json_rpc_server_test.go +++ b/rpc/v0/json_rpc_server_test.go @@ -15,7 +15,6 @@ package v0 import ( - "fmt" "testing" "github.com/eris-ltd/eris-db/account" @@ -35,10 +34,12 @@ func TestBroadcastTx(t *testing.T) { var tx txs.Tx = txs.NewCallTxWithNonce(pubKey, address, code, 10, 2, 1, 0) jsonBytes := wire.JSONBytesPretty(wrappedTx{tx}) - fmt.Println(string(jsonBytes)) request := NewRPCRequest("TestBroadcastTx", "BroacastTx", jsonBytes) - _, _, err := methods.BroadcastTx(request, "TestBroadcastTx") + result, _, err := methods.BroadcastTx(request, "TestBroadcastTx") assert.NoError(t, err) + receipt, ok := result.(*txs.Receipt) + assert.True(t, ok, "Should get Receipt pointer") + assert.Equal(t, txs.TxHash(testData.GetChainId.Output.ChainId, tx), receipt.TxHash) } // Allows us to get the type byte included but then omit the outer struct and diff --git a/rpc/rpc_test.go b/rpc/v0/json_rpc_test.go similarity index 99% rename from rpc/rpc_test.go rename to rpc/v0/json_rpc_test.go index fbdfca374c8cd4a764ea064d06e74ce5b5ca0e4b..54b45134353aa0168222a62d178f226c7e0ec9dc 100644 --- a/rpc/rpc_test.go +++ b/rpc/v0/json_rpc_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package rpc +package v0 import ( "testing" diff --git a/rpc/v0/methods.go b/rpc/v0/methods.go index bc661dd391d7bf3ee84f63aac274166b4701f375..14d88ac132ea7ca9e9c0affeb5e6bd65fc9cfffc 100644 --- a/rpc/v0/methods.go +++ b/rpc/v0/methods.go @@ -19,7 +19,6 @@ import ( core_types "github.com/eris-ltd/eris-db/core/types" definitions "github.com/eris-ltd/eris-db/definitions" "github.com/eris-ltd/eris-db/event" - "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/rpc/v0/shared" "github.com/eris-ltd/eris-db/txs" ) @@ -69,12 +68,12 @@ const ( // The rpc method handlers. type ErisDbMethods struct { - codec rpc.Codec + codec Codec pipe definitions.Pipe filterFactory *event.FilterFactory } -func NewErisDbMethods(codec rpc.Codec, +func NewErisDbMethods(codec Codec, pipe definitions.Pipe) *ErisDbMethods { return &ErisDbMethods{ @@ -85,7 +84,7 @@ func NewErisDbMethods(codec rpc.Codec, } // Used to handle requests. interface{} param is a wildcard used for example with socket events. -type RequestHandlerFunc func(*rpc.RPCRequest, interface{}) (interface{}, int, error) +type RequestHandlerFunc func(*RPCRequest, interface{}) (interface{}, int, error) // Private. Create a method name -> method handler map. func (erisDbMethods *ErisDbMethods) getMethods() map[string]RequestHandlerFunc { @@ -139,132 +138,132 @@ func (erisDbMethods *ErisDbMethods) getMethods() map[string]RequestHandlerFunc { // *************************************** Accounts *************************************** -func (erisDbMethods *ErisDbMethods) GenPrivAccount(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) GenPrivAccount(request *RPCRequest, requester interface{}) (interface{}, int, error) { pac, errC := erisDbMethods.pipe.Accounts().GenPrivAccount() if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return pac, 0, nil } -func (erisDbMethods *ErisDbMethods) GenPrivAccountFromKey(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) GenPrivAccountFromKey(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &PrivKeyParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } privKey := param.PrivKey pac, errC := erisDbMethods.pipe.Accounts().GenPrivAccountFromKey(privKey) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return pac, 0, nil } -func (erisDbMethods *ErisDbMethods) Account(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Account(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &AddressParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } address := param.Address // TODO is address check? account, errC := erisDbMethods.pipe.Accounts().Account(address) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return account, 0, nil } -func (erisDbMethods *ErisDbMethods) Accounts(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Accounts(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &AccountsParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } list, errC := erisDbMethods.pipe.Accounts().Accounts(param.Filters) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return list, 0, nil } -func (erisDbMethods *ErisDbMethods) AccountStorage(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) AccountStorage(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &AddressParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } address := param.Address storage, errC := erisDbMethods.pipe.Accounts().Storage(address) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return storage, 0, nil } -func (erisDbMethods *ErisDbMethods) AccountStorageAt(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) AccountStorageAt(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &StorageAtParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } address := param.Address key := param.Key storageItem, errC := erisDbMethods.pipe.Accounts().StorageAt(address, key) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return storageItem, 0, nil } // *************************************** Blockchain ************************************ -func (erisDbMethods *ErisDbMethods) BlockchainInfo(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) BlockchainInfo(request *RPCRequest, requester interface{}) (interface{}, int, error) { return shared.BlockchainInfo(erisDbMethods.pipe), 0, nil } -func (erisDbMethods *ErisDbMethods) ChainId(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) ChainId(request *RPCRequest, requester interface{}) (interface{}, int, error) { chainId := erisDbMethods.pipe.Blockchain().ChainId() return &core_types.ChainId{chainId}, 0, nil } -func (erisDbMethods *ErisDbMethods) GenesisHash(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) GenesisHash(request *RPCRequest, requester interface{}) (interface{}, int, error) { hash := erisDbMethods.pipe.GenesisHash() return &core_types.GenesisHash{hash}, 0, nil } -func (erisDbMethods *ErisDbMethods) LatestBlockHeight(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) LatestBlockHeight(request *RPCRequest, requester interface{}) (interface{}, int, error) { height := erisDbMethods.pipe.Blockchain().Height() return &core_types.LatestBlockHeight{height}, 0, nil } -func (erisDbMethods *ErisDbMethods) LatestBlock(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) LatestBlock(request *RPCRequest, requester interface{}) (interface{}, int, error) { latestHeight := erisDbMethods.pipe.Blockchain().Height() block := erisDbMethods.pipe.Blockchain().Block(latestHeight) return block, 0, nil } -func (erisDbMethods *ErisDbMethods) Blocks(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Blocks(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &BlocksParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } blocks, errC := blockchain.FilterBlocks(erisDbMethods.pipe.Blockchain(), erisDbMethods.filterFactory, param.Filters) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return blocks, 0, nil } -func (erisDbMethods *ErisDbMethods) Block(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Block(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &HeightParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } height := param.Height block := erisDbMethods.pipe.Blockchain().Block(height) @@ -273,51 +272,51 @@ func (erisDbMethods *ErisDbMethods) Block(request *rpc.RPCRequest, requester int // *************************************** Consensus ************************************ -func (erisDbMethods *ErisDbMethods) ConsensusState(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) ConsensusState(request *RPCRequest, requester interface{}) (interface{}, int, error) { return erisDbMethods.pipe.GetConsensusEngine().ConsensusState(), 0, nil } -func (erisDbMethods *ErisDbMethods) Validators(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Validators(request *RPCRequest, requester interface{}) (interface{}, int, error) { return erisDbMethods.pipe.GetConsensusEngine().ListValidators(), 0, nil } // *************************************** Net ************************************ -func (erisDbMethods *ErisDbMethods) NetworkInfo(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) NetworkInfo(request *RPCRequest, requester interface{}) (interface{}, int, error) { info := shared.NetInfo(erisDbMethods.pipe) return info, 0, nil } -func (erisDbMethods *ErisDbMethods) ClientVersion(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) ClientVersion(request *RPCRequest, requester interface{}) (interface{}, int, error) { version := shared.ClientVersion(erisDbMethods.pipe) return &core_types.ClientVersion{version}, 0, nil } -func (erisDbMethods *ErisDbMethods) Moniker(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Moniker(request *RPCRequest, requester interface{}) (interface{}, int, error) { moniker := shared.Moniker(erisDbMethods.pipe) return &core_types.Moniker{moniker}, 0, nil } -func (erisDbMethods *ErisDbMethods) Listening(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Listening(request *RPCRequest, requester interface{}) (interface{}, int, error) { listening := shared.Listening(erisDbMethods.pipe) return &core_types.Listening{listening}, 0, nil } -func (erisDbMethods *ErisDbMethods) Listeners(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Listeners(request *RPCRequest, requester interface{}) (interface{}, int, error) { listeners := shared.Listeners(erisDbMethods.pipe) return &core_types.Listeners{listeners}, 0, nil } -func (erisDbMethods *ErisDbMethods) Peers(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Peers(request *RPCRequest, requester interface{}) (interface{}, int, error) { peers := erisDbMethods.pipe.GetConsensusEngine().Peers() return peers, 0, nil } -func (erisDbMethods *ErisDbMethods) Peer(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Peer(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &PeerParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } address := param.Address peer := shared.Peer(erisDbMethods.pipe, address) @@ -326,166 +325,165 @@ func (erisDbMethods *ErisDbMethods) Peer(request *rpc.RPCRequest, requester inte // *************************************** Txs ************************************ -func (erisDbMethods *ErisDbMethods) Call(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Call(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &CallParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } from := param.From to := param.Address data := param.Data call, errC := erisDbMethods.pipe.Transactor().Call(from, to, data) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return call, 0, nil } -func (erisDbMethods *ErisDbMethods) CallCode(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) CallCode(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &CallCodeParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } from := param.From code := param.Code data := param.Data call, errC := erisDbMethods.pipe.Transactor().CallCode(from, code, data) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return call, 0, nil } -func (erisDbMethods *ErisDbMethods) BroadcastTx(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { - // Accept all transaction types as parameter for broadcast. - param := new(txs.Tx) - err := erisDbMethods.codec.DecodeBytes(param, request.Params) +func (erisDbMethods *ErisDbMethods) BroadcastTx(request *RPCRequest, requester interface{}) (interface{}, int, error) { + tx := new(txs.Tx) + err := erisDbMethods.codec.DecodeBytes(tx, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } - receipt, errC := erisDbMethods.pipe.Transactor().BroadcastTx(*param) + receipt, errC := erisDbMethods.pipe.Transactor().BroadcastTx(*tx) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return receipt, 0, nil } -func (erisDbMethods *ErisDbMethods) Transact(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) Transact(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &TransactParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } receipt, errC := erisDbMethods.pipe.Transactor().Transact(param.PrivKey, param.Address, param.Data, param.GasLimit, param.Fee) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return receipt, 0, nil } -func (erisDbMethods *ErisDbMethods) TransactAndHold(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) TransactAndHold(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &TransactParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } ce, errC := erisDbMethods.pipe.Transactor().TransactAndHold(param.PrivKey, param.Address, param.Data, param.GasLimit, param.Fee) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return ce, 0, nil } -func (this *ErisDbMethods) Send(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (this *ErisDbMethods) Send(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &SendParam{} err := this.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } receipt, errC := this.pipe.Transactor().Send(param.PrivKey, param.ToAddress, param.Amount) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return receipt, 0, nil } -func (this *ErisDbMethods) SendAndHold(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (this *ErisDbMethods) SendAndHold(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &SendParam{} err := this.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } rec, errC := this.pipe.Transactor().SendAndHold(param.PrivKey, param.ToAddress, param.Amount) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return rec, 0, nil } -func (erisDbMethods *ErisDbMethods) TransactNameReg(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) TransactNameReg(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &TransactNameRegParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } receipt, errC := erisDbMethods.pipe.Transactor().TransactNameReg(param.PrivKey, param.Name, param.Data, param.Amount, param.Fee) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return receipt, 0, nil } -func (erisDbMethods *ErisDbMethods) UnconfirmedTxs(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) UnconfirmedTxs(request *RPCRequest, requester interface{}) (interface{}, int, error) { trans, errC := erisDbMethods.pipe.GetConsensusEngine().ListUnconfirmedTxs(-1) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return txs.UnconfirmedTxs{trans}, 0, nil } -func (erisDbMethods *ErisDbMethods) SignTx(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) SignTx(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &SignTxParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } tx := param.Tx pAccs := param.PrivAccounts txRet, errC := erisDbMethods.pipe.Transactor().SignTx(tx, pAccs) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return txRet, 0, nil } // *************************************** Name Registry *************************************** -func (erisDbMethods *ErisDbMethods) NameRegEntry(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) NameRegEntry(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &NameRegEntryParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } name := param.Name // TODO is address check? entry, errC := erisDbMethods.pipe.NameReg().Entry(name) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return entry, 0, nil } -func (erisDbMethods *ErisDbMethods) NameRegEntries(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (erisDbMethods *ErisDbMethods) NameRegEntries(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &FilterListParam{} err := erisDbMethods.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } list, errC := erisDbMethods.pipe.NameReg().Entries(param.Filters) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return list, 0, nil } diff --git a/rpc/v0/restServer_pipe_test.go b/rpc/v0/mock_pipe_test.go similarity index 95% rename from rpc/v0/restServer_pipe_test.go rename to rpc/v0/mock_pipe_test.go index a45e88ec24ba39e3b6ecd49764d447cb21e5427e..6bb864d51f9cc57f42c2cdfbf56e7896ea088fca 100644 --- a/rpc/v0/restServer_pipe_test.go +++ b/rpc/v0/mock_pipe_test.go @@ -36,7 +36,7 @@ import ( // Base struct. type MockPipe struct { - testData *TestData + testData TestData accounts definitions.Accounts blockchain blockchain_types.Blockchain consensusEngine consensus_types.ConsensusEngine @@ -49,9 +49,9 @@ type MockPipe struct { // Create a new mock tendermint pipe. func NewMockPipe(td *TestData) definitions.Pipe { return &MockPipe{ - testData: td, + testData: *td, accounts: &accounts{td}, - blockchain: &mockBlockchain{td}, + blockchain: &chain{td}, consensusEngine: &consensusEngine{td}, events: &eventer{td}, namereg: &namereg{td}, @@ -152,23 +152,23 @@ func (acc *accounts) StorageAt(address, key []byte) (*core_types.StorageItem, er } // Blockchain -type mockBlockchain struct { +type chain struct { testData *TestData } -func (this *mockBlockchain) ChainId() string { +func (this *chain) ChainId() string { return this.testData.GetChainId.Output.ChainId } -func (this *mockBlockchain) Height() int { +func (this *chain) Height() int { return this.testData.GetLatestBlockHeight.Output.Height } -func (this *mockBlockchain) Block(height int) *mintTypes.Block { +func (this *chain) Block(height int) *mintTypes.Block { return this.testData.GetBlock.Output } -func (this *mockBlockchain) BlockMeta(height int) *mintTypes.BlockMeta { +func (this *chain) BlockMeta(height int) *mintTypes.BlockMeta { return &mintTypes.BlockMeta{} } @@ -276,7 +276,8 @@ func (trans *transactor) CallCode(from, code, data []byte) (*core_types.Call, er } func (trans *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { - return nil, nil + receipt := txs.GenerateReceipt(trans.testData.GetChainId.Output.ChainId, tx) + return &receipt, nil } func (trans *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*txs.Receipt, error) { diff --git a/rpc/v0/restServer_data_test.go b/rpc/v0/mock_test_data_test.go similarity index 95% rename from rpc/v0/restServer_data_test.go rename to rpc/v0/mock_test_data_test.go index c62c6f6224563df088874f6863a2c47817e6cc41..3722047b68a7e2280460bd79ff7464996ba17f0a 100644 --- a/rpc/v0/restServer_data_test.go +++ b/rpc/v0/mock_test_data_test.go @@ -557,22 +557,22 @@ type ( } GetAccountData struct { - Input *AddressParam `json:"input"` - Output *account.Account `json:"output"` + Input *AddressParam `json:"input"` + Output *account.Account `json:"output"` } GetAccountsData struct { - Input *AccountsParam `json:"input"` + Input *AccountsParam `json:"input"` Output *core_types.AccountList `json:"output"` } GetStorageData struct { - Input *AddressParam `json:"input"` - Output *core_types.Storage `json:"output"` + Input *AddressParam `json:"input"` + Output *core_types.Storage `json:"output"` } GetStorageAtData struct { - Input *StorageAtParam `json:"input"` + Input *StorageAtParam `json:"input"` Output *core_types.StorageItem `json:"output"` } @@ -601,13 +601,13 @@ type ( } GetBlockData struct { - Input *HeightParam `json:"input"` - Output *mintTypes.Block `json:"output"` + Input *HeightParam `json:"input"` + Output *mintTypes.Block `json:"output"` } GetBlocksData struct { - Input *BlocksParam `json:"input"` - Output *core_types.Blocks `json:"output"` + Input *BlocksParam `json:"input"` + Output *core_types.Blocks `json:"output"` } GetConsensusStateData struct { @@ -643,18 +643,18 @@ type ( } GetPeerData struct { - Input *PeerParam `json:"input"` + Input *PeerParam `json:"input"` Output *consensus_types.Peer `json:"output"` } TransactData struct { - Input *TransactParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Input *TransactParam `json:"input"` + Output *transaction.Receipt `json:"output"` } TransactCreateData struct { - Input *TransactParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Input *TransactParam `json:"input"` + Output *transaction.Receipt `json:"output"` } GetUnconfirmedTxsData struct { @@ -662,37 +662,37 @@ type ( } CallCodeData struct { - Input *CallCodeParam `json:"input"` - Output *core_types.Call `json:"output"` + Input *CallCodeParam `json:"input"` + Output *core_types.Call `json:"output"` } CallData struct { - Input *CallParam `json:"input"` - Output *core_types.Call `json:"output"` + Input *CallParam `json:"input"` + Output *core_types.Call `json:"output"` } EventSubscribeData struct { - Input *EventIdParam `json:"input"` - Output *event.EventSub `json:"output"` + Input *EventIdParam `json:"input"` + Output *event.EventSub `json:"output"` } EventUnsubscribeData struct { - Input *SubIdParam `json:"input"` - Output *event.EventUnsub `json:"output"` + Input *SubIdParam `json:"input"` + Output *event.EventUnsub `json:"output"` } TransactNameRegData struct { Input *TransactNameRegParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Output *transaction.Receipt `json:"output"` } GetNameRegEntryData struct { - Input *NameRegEntryParam `json:"input"` - Output *core_types.NameRegEntry `json:"output"` + Input *NameRegEntryParam `json:"input"` + Output *core_types.NameRegEntry `json:"output"` } GetNameRegEntriesData struct { - Input *FilterListParam `json:"input"` + Input *FilterListParam `json:"input"` Output *core_types.ResultListNames `json:"output"` } diff --git a/rpc/v0/restServer.go b/rpc/v0/rest_server.go similarity index 99% rename from rpc/v0/restServer.go rename to rpc/v0/rest_server.go index bc89b4225f25e1efb3ed038691dd7f1f8fe62ddc..a02c680406bd0e2ef6363f07b12c28370eb6d2b4 100644 --- a/rpc/v0/restServer.go +++ b/rpc/v0/rest_server.go @@ -26,7 +26,6 @@ import ( core_types "github.com/eris-ltd/eris-db/core/types" definitions "github.com/eris-ltd/eris-db/definitions" event "github.com/eris-ltd/eris-db/event" - "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/rpc/v0/shared" server "github.com/eris-ltd/eris-db/server" "github.com/eris-ltd/eris-db/txs" @@ -37,7 +36,7 @@ import ( // TODO more routers. Also, start looking into how better status codes // can be gotten. type RestServer struct { - codec rpc.Codec + codec Codec pipe definitions.Pipe eventSubs *event.EventSubscriptions filterFactory *event.FilterFactory @@ -45,7 +44,7 @@ type RestServer struct { } // Create a new rest server. -func NewRestServer(codec rpc.Codec, pipe definitions.Pipe, +func NewRestServer(codec Codec, pipe definitions.Pipe, eventSubs *event.EventSubscriptions) *RestServer { return &RestServer{ codec: codec, diff --git a/rpc/v0/restServer_test.go b/rpc/v0/rest_server_test.go similarity index 99% rename from rpc/v0/restServer_test.go rename to rpc/v0/rest_server_test.go index 77400a46920eecf72753c5e79325fcedfd188d0d..30906a9bf1d5f0a6e69a6d8138af63aa14011568 100644 --- a/rpc/v0/restServer_test.go +++ b/rpc/v0/rest_server_test.go @@ -28,7 +28,6 @@ import ( account "github.com/eris-ltd/eris-db/account" core_types "github.com/eris-ltd/eris-db/core/types" event "github.com/eris-ltd/eris-db/event" - rpc "github.com/eris-ltd/eris-db/rpc" server "github.com/eris-ltd/eris-db/server" "github.com/eris-ltd/eris-db/txs" @@ -51,7 +50,7 @@ type MockSuite struct { suite.Suite baseDir string serveProcess *server.ServeProcess - codec rpc.Codec + codec Codec sUrl string testData *TestData } diff --git a/rpc/v0/wsService.go b/rpc/v0/websocket_service.go similarity index 75% rename from rpc/v0/wsService.go rename to rpc/v0/websocket_service.go index 6e1eb9841e64149a55b1e4443b1ba52b1ef225a6..c1ffae951c0359c470b2db5267d519a8b4b8bb7e 100644 --- a/rpc/v0/wsService.go +++ b/rpc/v0/websocket_service.go @@ -20,21 +20,20 @@ import ( definitions "github.com/eris-ltd/eris-db/definitions" "github.com/eris-ltd/eris-db/event" - rpc "github.com/eris-ltd/eris-db/rpc" server "github.com/eris-ltd/eris-db/server" "github.com/eris-ltd/eris-db/txs" ) // Used for ErisDb. Implements WebSocketService. type ErisDbWsService struct { - codec rpc.Codec + codec Codec pipe definitions.Pipe defaultHandlers map[string]RequestHandlerFunc } // Create a new websocket service. -func NewErisDbWsService(codec rpc.Codec, - pipe definitions.Pipe) server.WebSocketService { +func NewErisDbWsService(codec Codec, + pipe definitions.Pipe) server.WebSocketService { tmwss := &ErisDbWsService{codec: codec, pipe: pipe} mtds := NewErisDbMethods(codec, pipe) @@ -49,18 +48,18 @@ func NewErisDbWsService(codec rpc.Codec, // Process a request. func (this *ErisDbWsService) Process(msg []byte, session *server.WSSession) { // Create new request object and unmarshal. - req := &rpc.RPCRequest{} + req := &RPCRequest{} errU := json.Unmarshal(msg, req) // Error when unmarshaling. if errU != nil { - this.writeError("Failed to parse request: "+errU.Error()+" . Raw: "+string(msg), "", rpc.PARSE_ERROR, session) + this.writeError("Failed to parse request: "+errU.Error()+" . Raw: "+string(msg), "", PARSE_ERROR, session) return } // Wrong protocol version. if req.JSONRPC != "2.0" { - this.writeError("Wrong protocol version: "+req.JSONRPC, req.Id, rpc.INVALID_REQUEST, session) + this.writeError("Wrong protocol version: "+req.JSONRPC, req.Id, INVALID_REQUEST, session) return } @@ -74,14 +73,14 @@ func (this *ErisDbWsService) Process(msg []byte, session *server.WSSession) { this.writeResponse(req.Id, resp, session) } } else { - this.writeError("Method not found: "+mName, req.Id, rpc.METHOD_NOT_FOUND, session) + this.writeError("Method not found: "+mName, req.Id, METHOD_NOT_FOUND, session) } } // Convenience method for writing error responses. func (this *ErisDbWsService) writeError(msg, id string, code int, session *server.WSSession) { - response := rpc.NewRPCErrorResponse(id, code, msg) + response := NewRPCErrorResponse(id, code, msg) bts, err := this.codec.EncodeBytes(response) // If there's an error here all bets are off. if err != nil { @@ -93,10 +92,10 @@ func (this *ErisDbWsService) writeError(msg, id string, code int, // Convenience method for writing responses. func (this *ErisDbWsService) writeResponse(id string, result interface{}, session *server.WSSession) error { - response := rpc.NewRPCResponse(id, result) + response := NewRPCResponse(id, result) bts, err := this.codec.EncodeBytes(response) if err != nil { - this.writeError("Internal error: "+err.Error(), id, rpc.INTERNAL_ERROR, session) + this.writeError("Internal error: "+err.Error(), id, INTERNAL_ERROR, session) return err } return session.Write(bts) @@ -104,22 +103,22 @@ func (this *ErisDbWsService) writeResponse(id string, result interface{}, // *************************************** Events ************************************ -func (this *ErisDbWsService) EventSubscribe(request *rpc.RPCRequest, +func (this *ErisDbWsService) EventSubscribe(request *RPCRequest, requester interface{}) (interface{}, int, error) { session, ok := requester.(*server.WSSession) if !ok { - return 0, rpc.INTERNAL_ERROR, + return 0, INTERNAL_ERROR, fmt.Errorf("Passing wrong object to websocket events") } param := &EventIdParam{} err := this.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } eventId := param.EventId subId, errSID := event.GenerateSubId() if errSID != nil { - return nil, rpc.INTERNAL_ERROR, errSID + return nil, INTERNAL_ERROR, errSID } callback := func(ret txs.EventData) { @@ -127,26 +126,26 @@ func (this *ErisDbWsService) EventSubscribe(request *rpc.RPCRequest, } errC := this.pipe.Events().Subscribe(subId, eventId, callback) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return &event.EventSub{subId}, 0, nil } -func (this *ErisDbWsService) EventUnsubscribe(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { +func (this *ErisDbWsService) EventUnsubscribe(request *RPCRequest, requester interface{}) (interface{}, int, error) { param := &EventIdParam{} err := this.codec.DecodeBytes(param, request.Params) if err != nil { - return nil, rpc.INVALID_PARAMS, err + return nil, INVALID_PARAMS, err } eventId := param.EventId errC := this.pipe.Events().Unsubscribe(eventId) if errC != nil { - return nil, rpc.INTERNAL_ERROR, errC + return nil, INTERNAL_ERROR, errC } return &event.EventUnsub{true}, 0, nil } -func (this *ErisDbWsService) EventPoll(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { - return nil, rpc.INTERNAL_ERROR, fmt.Errorf("Cannot poll with websockets") +func (this *ErisDbWsService) EventPoll(request *RPCRequest, requester interface{}) (interface{}, int, error) { + return nil, INTERNAL_ERROR, fmt.Errorf("Cannot poll with websockets") } diff --git a/test/server/scumbag.go b/test/server/scumbag.go index 67751442e23b3b5ad948fb0b88ce33a8758ab9f3..4a0b4f115d2cd79014205cd68550a0129a762299 100644 --- a/test/server/scumbag.go +++ b/test/server/scumbag.go @@ -19,10 +19,10 @@ import ( "os" "runtime" - rpc "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/server" "github.com/gin-gonic/gin" "github.com/tendermint/log15" + "github.com/eris-ltd/eris-db/rpc/v0" ) func init() { @@ -60,7 +60,7 @@ func (this *ScumbagServer) ShutDown() { type ScumSocketService struct{} func (this *ScumSocketService) Process(data []byte, session *server.WSSession) { - resp := rpc.NewRPCResponse("1", "Scumbag") + resp := v0.NewRPCResponse("1", "Scumbag") bts, _ := json.Marshal(resp) session.Write(bts) }