diff --git a/erisdb/codec.go b/erisdb/codec.go index 04055df146a93af48b05a10abe4e1e71f5814979..f72bcd3ad97a6aa491b7f6f5928f33b1087af4b4 100644 --- a/erisdb/codec.go +++ b/erisdb/codec.go @@ -1,10 +1,11 @@ package erisdb import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" - rpc "github.com/eris-ltd/eris-db/rpc" "io" "io/ioutil" + + "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + rpc "github.com/eris-ltd/eris-db/rpc" ) // Codec that uses tendermints 'binary' package for JSON. diff --git a/erisdb/methods.go b/erisdb/methods.go index 0b0a370eee5fdb224a8d6f52a686caef700c5ff4..2adfc77874fd538f6fca39c2bab4f16f027dc972 100644 --- a/erisdb/methods.go +++ b/erisdb/methods.go @@ -3,10 +3,13 @@ package erisdb import ( "crypto/rand" "encoding/hex" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "strings" + ep "github.com/eris-ltd/eris-db/erisdb/pipe" rpc "github.com/eris-ltd/eris-db/rpc" - "strings" + + "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" ) // TODO use the method name definition file. @@ -381,12 +384,14 @@ func (this *ErisDbMethods) CallCode(request *rpc.RPCRequest, requester interface } func (this *ErisDbMethods) BroadcastTx(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { - param := &types.CallTx{} - err := this.codec.DecodeBytes(param, request.Params) + var err error + // Special because Tx is an interface + param := new(types.Tx) + wire.ReadJSONPtr(param, request.Params, &err) if err != nil { return nil, rpc.INVALID_PARAMS, err } - receipt, errC := this.pipe.Transactor().BroadcastTx(param) + receipt, errC := this.pipe.Transactor().BroadcastTx(*param) if errC != nil { return nil, rpc.INTERNAL_ERROR, errC } diff --git a/erisdb/restServer.go b/erisdb/restServer.go index 5585d572559fc2e1c8caebad3889167939df25c7..cf428321456eb9184ca7cfb6e021f0cd25fe65cd 100644 --- a/erisdb/restServer.go +++ b/erisdb/restServer.go @@ -3,14 +3,18 @@ package erisdb import ( "encoding/hex" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "io/ioutil" + "strconv" + "strings" + ep "github.com/eris-ltd/eris-db/erisdb/pipe" rpc "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/server" "github.com/eris-ltd/eris-db/util" - "strconv" - "strings" + + "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" ) // Provides a REST-like web-api. Implements server.Server @@ -372,12 +376,15 @@ func (this *RestServer) handlePeer(c *gin.Context) { // ********************************* Transactions ********************************* func (this *RestServer) handleBroadcastTx(c *gin.Context) { - param := &types.CallTx{} - errD := this.codec.Decode(param, c.Request.Body) - if errD != nil { - c.AbortWithError(500, errD) + // Special because Tx is an interface + param := new(types.Tx) + b, err := ioutil.ReadAll(c.Request.Body) + defer c.Request.Body.Close() + wire.ReadJSONPtr(param, b, &err) + if err != nil { + c.AbortWithError(500, err) } - receipt, err := this.pipe.Transactor().BroadcastTx(param) + receipt, err := this.pipe.Transactor().BroadcastTx(*param) if err != nil { c.AbortWithError(500, err) }