diff --git a/definitions/tendermint_pipe.go b/definitions/tendermint_pipe.go index 054c409318bbc0c8b8a8d11cc090c73b05f8f379..01d5d849827ae233d70302012ce69e41cf1fb2bd 100644 --- a/definitions/tendermint_pipe.go +++ b/definitions/tendermint_pipe.go @@ -18,8 +18,8 @@ package definitions import ( account "github.com/eris-ltd/eris-db/account" - "github.com/eris-ltd/eris-db/txs" rpc_tendermint_types "github.com/eris-ltd/eris-db/rpc/tendermint/core/types" + "github.com/eris-ltd/eris-db/txs" ) // NOTE: [ben] TendermintPipe is the additional pipe to carry over diff --git a/manager/eris-mint/eris-mint.go b/manager/eris-mint/eris-mint.go index 1865b995f8e3b5f67d71aaf6d0ac2fa38a2a3835..fb86908318454066ad3ba61f10d7e2cd2b49ed50 100644 --- a/manager/eris-mint/eris-mint.go +++ b/manager/eris-mint/eris-mint.go @@ -23,9 +23,9 @@ import ( "sync" tendermint_events "github.com/tendermint/go-events" + rpcclient "github.com/tendermint/go-rpc/client" wire "github.com/tendermint/go-wire" ctypes "github.com/tendermint/tendermint/rpc/core/types" - rpcclient "github.com/tendermint/go-rpc/client" tmsp "github.com/tendermint/tmsp/types" log "github.com/eris-ltd/eris-logger" diff --git a/manager/eris-mint/namereg.go b/manager/eris-mint/namereg.go index b40da38f931b278d5d1599d11b17651185311acb..25d95ffad3f97d19b654e8917c2e45a47900087d 100644 --- a/manager/eris-mint/namereg.go +++ b/manager/eris-mint/namereg.go @@ -96,7 +96,7 @@ func (this *namereg) Entries(filters []*event.FilterData) (*core_types.ResultLis } type ResultListNames struct { - BlockHeight int `json:"block_height"` + BlockHeight int `json:"block_height"` Names []*core_types.NameRegEntry `json:"names"` } diff --git a/manager/eris-mint/pipe.go b/manager/eris-mint/pipe.go index dc8952e83c71e80b48cb035816e3cb8b3ddc2802..02c06af91bf94046a928f4d611e0c3971c7e49c7 100644 --- a/manager/eris-mint/pipe.go +++ b/manager/eris-mint/pipe.go @@ -32,6 +32,7 @@ import ( account "github.com/eris-ltd/eris-db/account" config "github.com/eris-ltd/eris-db/config" + 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" vm "github.com/eris-ltd/eris-db/manager/eris-mint/evm" @@ -39,7 +40,6 @@ import ( state_types "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" manager_types "github.com/eris-ltd/eris-db/manager/types" rpc_tendermint_types "github.com/eris-ltd/eris-db/rpc/tendermint/core/types" - core_types "github.com/eris-ltd/eris-db/core/types" "github.com/eris-ltd/eris-db/txs" ) diff --git a/rpc/tendermint/client/client.go b/rpc/tendermint/client/client.go index 8b35b99d6c59bd69d28b89cebc532a4f6e22eca5..75731a20aa5b2cc560f85b7f434a41653dc5e015 100644 --- a/rpc/tendermint/client/client.go +++ b/rpc/tendermint/client/client.go @@ -4,8 +4,8 @@ import ( "fmt" acm "github.com/eris-ltd/eris-db/account" core_types "github.com/eris-ltd/eris-db/core/types" - "github.com/eris-ltd/eris-db/txs" rpc_types "github.com/eris-ltd/eris-db/rpc/tendermint/core/types" + "github.com/eris-ltd/eris-db/txs" rpcclient "github.com/tendermint/go-rpc/client" "github.com/tendermint/go-wire" ) diff --git a/rpc/tendermint/core/routes.go b/rpc/tendermint/core/routes.go index e7d4e5f193bb0eac05045ec0da6743c477c0d191..ea041d305f0e0a3b6258a2cd2c04555db6f806e2 100644 --- a/rpc/tendermint/core/routes.go +++ b/rpc/tendermint/core/routes.go @@ -4,9 +4,9 @@ import ( "fmt" acm "github.com/eris-ltd/eris-db/account" - "github.com/eris-ltd/eris-db/txs" "github.com/eris-ltd/eris-db/definitions" ctypes "github.com/eris-ltd/eris-db/rpc/tendermint/core/types" + "github.com/eris-ltd/eris-db/txs" rpc "github.com/tendermint/go-rpc/server" ) diff --git a/rpc/tendermint/core/types/responses.go b/rpc/tendermint/core/types/responses.go index 192727335620941da526e45a8eba580dbcd6d93f..4c48f7ab7a5410ef1dc6cb488218fa54e88895f8 100644 --- a/rpc/tendermint/core/types/responses.go +++ b/rpc/tendermint/core/types/responses.go @@ -101,7 +101,7 @@ type ResultBroadcastTx struct { } type ResultListUnconfirmedTxs struct { - N int `json:"n_txs"` + N int `json:"n_txs"` Txs []txs.Tx `json:"txs"` } diff --git a/rpc/tendermint/test/tests.go b/rpc/tendermint/test/tests.go index 7bcce656d4268cc06d7a20f4c52ffd44bce07c1e..f09a552431ee8efc83bba5438b7dd32d4c5a16ed 100644 --- a/rpc/tendermint/test/tests.go +++ b/rpc/tendermint/test/tests.go @@ -72,8 +72,8 @@ func testBroadcastTx(t *testing.T, typ string) { hasher.Write(goWireBytes) txHashExpected := hasher.Sum(nil) if bytes.Compare(receipt.TxHash, txHashExpected) != 0 { - t.Fatalf("The receipt hash '%x' does not equal the ripemd160 hash of the " + - "transaction signed bytes calculated in the test: '%x'", + t.Fatalf("The receipt hash '%x' does not equal the ripemd160 hash of the "+ + "transaction signed bytes calculated in the test: '%x'", receipt.TxHash, txHashExpected) } } diff --git a/rpc/v0/json_service.go b/rpc/v0/json_service.go index e7226487d58613cd50961b827d257e57078aeab9..adce33f211aec98d9c5eb9c339596ec2fc8424d5 100644 --- a/rpc/v0/json_service.go +++ b/rpc/v0/json_service.go @@ -27,7 +27,8 @@ func NewJsonRpcServer(service server.HttpService) *JsonRpcServer { } // Start adds the rpc path to the router. -func (this *JsonRpcServer) Start(config *server.ServerConfig, router *gin.Engine) { +func (this *JsonRpcServer) Start(config *server.ServerConfig, + router *gin.Engine) { router.POST(config.HTTP.JsonRpcEndpoint, this.handleFunc) this.running = true } @@ -85,13 +86,15 @@ func (this *ErisDbJsonService) Process(r *http.Request, w http.ResponseWriter) { // Error when decoding. if errU != nil { - this.writeError("Failed to parse request: "+errU.Error(), "", rpc_tendermint.PARSE_ERROR, w) + this.writeError("Failed to parse request: "+errU.Error(), "", + rpc_tendermint.PARSE_ERROR, w) return } // Wrong protocol version. if req.JSONRPC != "2.0" { - this.writeError("Wrong protocol version: "+req.JSONRPC, req.Id, rpc_tendermint.INVALID_REQUEST, w) + this.writeError("Wrong protocol version: "+req.JSONRPC, req.Id, + rpc_tendermint.INVALID_REQUEST, w) return } @@ -137,7 +140,8 @@ func (this *ErisDbJsonService) writeResponse(id string, result interface{}, w ht // *************************************** Events ************************************ // Subscribe to an event. -func (this *ErisDbJsonService) EventSubscribe(request *rpc_tendermint.RPCRequest, requester interface{}) (interface{}, int, error) { +func (this *ErisDbJsonService) EventSubscribe(request *rpc_tendermint.RPCRequest, + requester interface{}) (interface{}, int, error) { param := &EventIdParam{} err := json.Unmarshal(request.Params, param) if err != nil { @@ -152,7 +156,8 @@ func (this *ErisDbJsonService) EventSubscribe(request *rpc_tendermint.RPCRequest } // Un-subscribe from an event. -func (this *ErisDbJsonService) EventUnsubscribe(request *rpc_tendermint.RPCRequest, requester interface{}) (interface{}, int, error) { +func (this *ErisDbJsonService) EventUnsubscribe(request *rpc_tendermint.RPCRequest, + requester interface{}) (interface{}, int, error) { param := &SubIdParam{} err := json.Unmarshal(request.Params, param) if err != nil { @@ -168,7 +173,8 @@ func (this *ErisDbJsonService) EventUnsubscribe(request *rpc_tendermint.RPCReque } // Check subscription event cache for new data. -func (this *ErisDbJsonService) EventPoll(request *rpc_tendermint.RPCRequest, requester interface{}) (interface{}, int, error) { +func (this *ErisDbJsonService) EventPoll(request *rpc_tendermint.RPCRequest, + requester interface{}) (interface{}, int, error) { param := &SubIdParam{} err := json.Unmarshal(request.Params, param) if err != nil { diff --git a/txs/events.go b/txs/events.go index c76f3b9d418329f8b9127f3d95f11e7e26fa694c..14185c3a0cb7591a100feae2023df146aea8921c 100644 --- a/txs/events.go +++ b/txs/events.go @@ -72,9 +72,9 @@ type EventDataNewBlock struct { // All txs fire EventDataTx, but only CallTx might have Return or Exception type EventDataTx struct { - Tx Tx `json:"tx"` - Return []byte `json:"return"` - Exception string `json:"exception"` + Tx Tx `json:"tx"` + Return []byte `json:"return"` + Exception string `json:"exception"` } // EventDataCall fires when we call a contract, and when a contract calls another contract diff --git a/txs/tx.go b/txs/tx.go index b97c95d6c746b984f99fb72bc7811d78e49ccfb7..9957d570060d6c37ae266e8fc3b75adcb63e7796 100644 --- a/txs/tx.go +++ b/txs/tx.go @@ -18,15 +18,15 @@ import ( ) var ( - ErrTxInvalidAddress = errors.New("Error invalid address") - ErrTxDuplicateAddress = errors.New("Error duplicate address") - ErrTxInvalidAmount = errors.New("Error invalid amount") - ErrTxInsufficientFunds = errors.New("Error insufficient funds") + ErrTxInvalidAddress = errors.New("Error invalid address") + ErrTxDuplicateAddress = errors.New("Error duplicate address") + ErrTxInvalidAmount = errors.New("Error invalid amount") + ErrTxInsufficientFunds = errors.New("Error insufficient funds") ErrTxInsufficientGasPrice = errors.New("Error insufficient gas price") - ErrTxUnknownPubKey = errors.New("Error unknown pubkey") - ErrTxInvalidPubKey = errors.New("Error invalid pubkey") - ErrTxInvalidSignature = errors.New("Error invalid signature") - ErrTxPermissionDenied = errors.New("Error permission denied") + ErrTxUnknownPubKey = errors.New("Error unknown pubkey") + ErrTxInvalidPubKey = errors.New("Error invalid pubkey") + ErrTxInvalidSignature = errors.New("Error invalid signature") + ErrTxPermissionDenied = errors.New("Error permission denied") ) type ErrTxInvalidString struct { @@ -71,9 +71,9 @@ const ( TxTypeName = byte(0x03) // Validation transactions - TxTypeBond = byte(0x11) - TxTypeUnbond = byte(0x12) - TxTypeRebond = byte(0x13) + TxTypeBond = byte(0x11) + TxTypeUnbond = byte(0x12) + TxTypeRebond = byte(0x13) TxTypeDupeout = byte(0x14) // Admin transactions @@ -82,7 +82,7 @@ const ( // for wire.readReflect var _ = wire.RegisterInterface( - struct{ Tx }{}, + struct{ Tx }{}, wire.ConcreteType{&SendTx{}, TxTypeSend}, wire.ConcreteType{&CallTx{}, TxTypeCall}, wire.ConcreteType{&NameTx{}, TxTypeName}, @@ -95,7 +95,7 @@ var _ = wire.RegisterInterface( //----------------------------------------------------------------------------- -type( +type ( Tx interface { WriteSignBytes(chainID string, w io.Writer, n *int, err *error) } @@ -191,14 +191,14 @@ func (tx *SendTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeSend)), w, n, err) for i, in := range tx.Inputs { in.WriteSignBytes(w, n, err) - if i != len(tx.Inputs) - 1 { + if i != len(tx.Inputs)-1 { wire.WriteTo([]byte(","), w, n, err) } } wire.WriteTo([]byte(`],"outputs":[`), w, n, err) for i, out := range tx.Outputs { out.WriteSignBytes(w, n, err) - if i != len(tx.Outputs) - 1 { + if i != len(tx.Outputs)-1 { wire.WriteTo([]byte(","), w, n, err) } } @@ -224,7 +224,7 @@ func (tx *CallTx) String() string { } func NewContractAddress(caller []byte, nonce int) []byte { - temp := make([]byte, 32 + 8) + temp := make([]byte, 32+8) copy(temp, caller) PutInt64BE(temp[32:], int64(nonce)) hasher := ripemd160.New() @@ -283,7 +283,7 @@ func (tx *BondTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeBond)), w, n, err) for i, in := range tx.Inputs { in.WriteSignBytes(w, n, err) - if i != len(tx.Inputs) - 1 { + if i != len(tx.Inputs)-1 { wire.WriteTo([]byte(","), w, n, err) } } @@ -292,7 +292,7 @@ func (tx *BondTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error wire.WriteTo([]byte(`,"unbond_to":[`), w, n, err) for i, out := range tx.UnbondTo { out.WriteSignBytes(w, n, err) - if i != len(tx.UnbondTo) - 1 { + if i != len(tx.UnbondTo)-1 { wire.WriteTo([]byte(","), w, n, err) } }