Merge pull request #53 from tendermint/go-rpc-9-with-key-value-params-jsonrpc

go-rpc updates
This commit is contained in:
Ethan Buchman 2017-04-13 21:54:07 -04:00 committed by GitHub
commit 221421ad3e
5 changed files with 28 additions and 29 deletions

View File

@ -1,22 +1,22 @@
all: test install all: test install
NOVENDOR = go list github.com/tendermint/basecoin/... | grep -v /vendor/ NOVENDOR = go list ./... | grep -v /vendor/
build: build:
go build github.com/tendermint/basecoin/cmd/... go build ./cmd/...
install: install:
go install github.com/tendermint/basecoin/cmd/... go install ./cmd/...
test: test:
go test `${NOVENDOR}` go test `${NOVENDOR}`
#go run tests/tendermint/*.go #go run tests/tendermint/*.go
get_deps: get_deps:
go get -d github.com/tendermint/basecoin/... go get -d ./...
update_deps: update_deps:
go get -d -u github.com/tendermint/basecoin/... go get -d -u ./...
get_vendor_deps: get_vendor_deps:
go get github.com/Masterminds/glide go get github.com/Masterminds/glide

View File

@ -12,7 +12,7 @@ import (
cmn "github.com/tendermint/go-common" cmn "github.com/tendermint/go-common"
client "github.com/tendermint/go-rpc/client" client "github.com/tendermint/go-rpc/client"
"github.com/tendermint/go-wire" wire "github.com/tendermint/go-wire"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
) )
@ -189,14 +189,14 @@ func AppTx(c *cli.Context, name string, data []byte) error {
func broadcastTx(c *cli.Context, tx types.Tx) ([]byte, string, error) { func broadcastTx(c *cli.Context, tx types.Tx) ([]byte, string, error) {
tmResult := new(ctypes.TMResult) tmResult := new(ctypes.TMResult)
tmAddr := c.String("node") tmAddr := c.String("node")
clientURI := client.NewURIClient(tmAddr) uriClient := client.NewURIClient(tmAddr)
// Don't you hate having to do this? // Don't you hate having to do this?
// How many times have I lost an hour over this trick?! // How many times have I lost an hour over this trick?!
txBytes := []byte(wire.BinaryBytes(struct { txBytes := []byte(wire.BinaryBytes(struct {
types.Tx `json:"unwrap"` types.Tx `json:"unwrap"`
}{tx})) }{tx}))
_, err := clientURI.Call("broadcast_tx_commit", map[string]interface{}{"tx": txBytes}, tmResult) _, err := uriClient.Call("broadcast_tx_commit", map[string]interface{}{"tx": txBytes}, tmResult)
if err != nil { if err != nil {
return nil, "", errors.New(cmn.Fmt("Error on broadcast tx: %v", err)) return nil, "", errors.New(cmn.Fmt("Error on broadcast tx: %v", err))
} }

View File

@ -16,7 +16,7 @@ import (
abci "github.com/tendermint/abci/types" abci "github.com/tendermint/abci/types"
cmn "github.com/tendermint/go-common" cmn "github.com/tendermint/go-common"
client "github.com/tendermint/go-rpc/client" client "github.com/tendermint/go-rpc/client"
"github.com/tendermint/go-wire" wire "github.com/tendermint/go-wire"
ctypes "github.com/tendermint/tendermint/rpc/core/types" ctypes "github.com/tendermint/tendermint/rpc/core/types"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
) )
@ -89,7 +89,7 @@ func ParseCoins(str string) (types.Coins, error) {
} }
func Query(tmAddr string, key []byte) (*abci.ResponseQuery, error) { func Query(tmAddr string, key []byte) (*abci.ResponseQuery, error) {
clientURI := client.NewURIClient(tmAddr) uriClient := client.NewURIClient(tmAddr)
tmResult := new(ctypes.TMResult) tmResult := new(ctypes.TMResult)
params := map[string]interface{}{ params := map[string]interface{}{
@ -97,7 +97,7 @@ func Query(tmAddr string, key []byte) (*abci.ResponseQuery, error) {
"data": key, "data": key,
"prove": true, "prove": true,
} }
_, err := clientURI.Call("abci_query", params, tmResult) _, err := uriClient.Call("abci_query", params, tmResult)
if err != nil { if err != nil {
return nil, errors.New(cmn.Fmt("Error calling /abci_query: %v", err)) return nil, errors.New(cmn.Fmt("Error calling /abci_query: %v", err))
} }
@ -136,10 +136,10 @@ func getAcc(tmAddr string, address []byte) (*types.Account, error) {
func getHeaderAndCommit(c *cli.Context, height int) (*tmtypes.Header, *tmtypes.Commit, error) { func getHeaderAndCommit(c *cli.Context, height int) (*tmtypes.Header, *tmtypes.Commit, error) {
tmResult := new(ctypes.TMResult) tmResult := new(ctypes.TMResult)
tmAddr := c.String("node") tmAddr := c.String("node")
clientURI := client.NewURIClient(tmAddr) uriClient := client.NewURIClient(tmAddr)
method := "commit" method := "commit"
_, err := clientURI.Call(method, map[string]interface{}{"height": height}, tmResult) _, err := uriClient.Call(method, map[string]interface{}{"height": height}, tmResult)
if err != nil { if err != nil {
return nil, nil, errors.New(cmn.Fmt("Error on %s: %v", method, err)) return nil, nil, errors.New(cmn.Fmt("Error on %s: %v", method, err))
} }

27
glide.lock generated
View File

@ -1,18 +1,18 @@
hash: 3869944d14a8df914ffcad02c2ef3548173daba51c5ea697767f8af77c07b348 hash: 3869944d14a8df914ffcad02c2ef3548173daba51c5ea697767f8af77c07b348
updated: 2017-04-13T14:20:12.625211087+02:00 updated: 2017-04-13T21:40:19.30156119-04:00
imports: imports:
- name: github.com/btcsuite/btcd - name: github.com/btcsuite/btcd
version: 583684b21bfbde9b5fc4403916fd7c807feb0289 version: 583684b21bfbde9b5fc4403916fd7c807feb0289
subpackages: subpackages:
- btcec - btcec
- name: github.com/BurntSushi/toml - name: github.com/BurntSushi/toml
version: e643e9ef00b049d75de26e61109c5ea01885cd21 version: 99064174e013895bbd9b025c31100bd1d9b590ca
- name: github.com/ebuchman/fail-test - name: github.com/ebuchman/fail-test
version: 95f809107225be108efcf10a3509e4ea6ceef3c4 version: 95f809107225be108efcf10a3509e4ea6ceef3c4
- name: github.com/go-stack/stack - name: github.com/go-stack/stack
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82 version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
- name: github.com/golang/protobuf - name: github.com/golang/protobuf
version: c9c7427a2a70d2eb3bafa0ab2dc163e45f143317 version: 69b215d01a5606c843240eab4937eab3acee6530
subpackages: subpackages:
- proto - proto
- name: github.com/golang/snappy - name: github.com/golang/snappy
@ -22,11 +22,11 @@ imports:
- name: github.com/jmhodges/levigo - name: github.com/jmhodges/levigo
version: c42d9e0ca023e2198120196f842701bb4c55d7b9 version: c42d9e0ca023e2198120196f842701bb4c55d7b9
- name: github.com/mattn/go-colorable - name: github.com/mattn/go-colorable
version: a392f450ea64cee2b268dfaacdc2502b50a22b18 version: acb9493f2794fd0f820de7a27a217dafbb1b65ea
- name: github.com/mattn/go-isatty - name: github.com/mattn/go-isatty
version: 57fdcb988a5c543893cc61bce354a6e24ab70022 version: 9622e0cc9d8f9be434ca605520ff9a16808fee47
- name: github.com/pkg/errors - name: github.com/pkg/errors
version: bfd5150e4e41705ded2129ec33379de1cb90b513 version: 645ef00459ed84a119197bfb8d8205042c6df63d
- name: github.com/syndtr/goleveldb - name: github.com/syndtr/goleveldb
version: 3c5717caf1475fd25964109a0fc640bd150fce43 version: 3c5717caf1475fd25964109a0fc640bd150fce43
subpackages: subpackages:
@ -83,13 +83,13 @@ imports:
subpackages: subpackages:
- upnp - upnp
- name: github.com/tendermint/go-rpc - name: github.com/tendermint/go-rpc
version: 9d18cbe74e66f875afa36d2fa3be280e4a2dc9e6 version: c3295f4878019ff3fdfcac37a4c0e4bcf4bb02a7
subpackages: subpackages:
- client - client
- server - server
- types - types
- name: github.com/tendermint/go-wire - name: github.com/tendermint/go-wire
version: 50889e2b4a9ba65b67be86a486f25853d514b937 version: ad797c70affa2c81fccc5edaed63ac25144397c6
- name: github.com/tendermint/log15 - name: github.com/tendermint/log15
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6 version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
subpackages: subpackages:
@ -115,9 +115,9 @@ imports:
- types - types
- version - version
- name: github.com/urfave/cli - name: github.com/urfave/cli
version: 0bdeddeeb0f650497d603c4ad7b20cfe685682f6 version: 8ef3805c9de2519805c3f060524b695bba2cd715
- name: golang.org/x/crypto - name: golang.org/x/crypto
version: 728b753d0135da6801d45a38e6f43ff55779c5c2 version: 40541ccb1c6e64c947ed6f606b8a6cb4b67d7436
subpackages: subpackages:
- curve25519 - curve25519
- nacl/box - nacl/box
@ -128,7 +128,7 @@ imports:
- ripemd160 - ripemd160
- salsa20/salsa - salsa20/salsa
- name: golang.org/x/net - name: golang.org/x/net
version: a6577fac2d73be281a500b310739095313165611 version: d379faa25cbdc04d653984913a2ceb43b0bc46d7
subpackages: subpackages:
- context - context
- http2 - http2
@ -138,17 +138,16 @@ imports:
- lex/httplex - lex/httplex
- trace - trace
- name: golang.org/x/sys - name: golang.org/x/sys
version: 99f16d856c9836c42d24e7ab64ea72916925fa97 version: e48874b42435b4347fc52bdee0424a52abc974d7
subpackages: subpackages:
- unix - unix
- name: google.golang.org/grpc - name: google.golang.org/grpc
version: 0713829b980f4ddd276689a36235c5fcc82a21bf version: 7b399ed358736bc5522021cdc7d79a8ee9ac6f98
subpackages: subpackages:
- codes - codes
- credentials - credentials
- grpclog - grpclog
- internal - internal
- keepalive
- metadata - metadata
- naming - naming
- peer - peer

View File

@ -8,9 +8,9 @@ import (
"github.com/tendermint/basecoin/types" "github.com/tendermint/basecoin/types"
cmn "github.com/tendermint/go-common" cmn "github.com/tendermint/go-common"
crypto "github.com/tendermint/go-crypto" crypto "github.com/tendermint/go-crypto"
"github.com/tendermint/go-rpc/client" rpcclient "github.com/tendermint/go-rpc/client"
"github.com/tendermint/go-rpc/types" "github.com/tendermint/go-rpc/types"
"github.com/tendermint/go-wire" wire "github.com/tendermint/go-wire"
_ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types _ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types
) )