mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-18 07:31:20 +00:00
fixes from @cloudhead review
This commit is contained in:
@ -70,13 +70,13 @@ func (c *HTTP) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *HTTP) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
func (c *HTTP) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||||
return c.ABCIQueryWithOptions(path, data, DefaultABCIQueryOptions())
|
return c.ABCIQueryWithOptions(path, data, DefaultABCIQueryOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HTTP) ABCIQueryWithOptions(path string, data data.Bytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
func (c *HTTP) ABCIQueryWithOptions(path string, data data.Bytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||||
result := new(ctypes.ResultABCIQuery)
|
result := new(ctypes.ResultABCIQuery)
|
||||||
_, err := c.rpc.Call("abci_query",
|
_, err := c.rpc.Call("abci_query",
|
||||||
map[string]interface{}{"path": path, "data": data, "height": opts.Height, "prove": opts.Prove},
|
map[string]interface{}{"path": path, "data": data, "height": opts.Height, "trusted": opts.Trusted},
|
||||||
result)
|
result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "ABCIQuery")
|
return nil, errors.Wrap(err, "ABCIQuery")
|
||||||
|
@ -58,11 +58,11 @@ func (c Local) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c Local) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
func (c Local) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||||
return c.ABCIQueryWithOptions(path, data, DefaultABCIQueryOptions())
|
return c.ABCIQueryWithOptions(path, data, DefaultABCIQueryOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Local) ABCIQueryWithOptions(path string, data data.Bytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
func (c Local) ABCIQueryWithOptions(path string, data data.Bytes, opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||||
return core.ABCIQuery(path, data, opts.Height, opts.Prove)
|
return core.ABCIQuery(path, data, opts.Height, opts.Trusted)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Local) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
func (c Local) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||||
|
@ -25,11 +25,11 @@ func (a ABCIApp) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a ABCIApp) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
func (a ABCIApp) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||||
return a.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions())
|
return a.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a ABCIApp) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
func (a ABCIApp) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||||
q := a.App.Query(abci.RequestQuery{data, path, opts.Height, opts.Prove})
|
q := a.App.Query(abci.RequestQuery{data, path, opts.Height, opts.Trusted})
|
||||||
return &ctypes.ResultABCIQuery{q.Result()}, nil
|
return &ctypes.ResultABCIQuery{q.Result()}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,11 +84,11 @@ func (m ABCIMock) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m ABCIMock) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
func (m ABCIMock) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||||
return m.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions())
|
return m.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m ABCIMock) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
func (m ABCIMock) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||||
res, err := m.Query.GetResponse(QueryArgs{path, data, opts.Height, opts.Prove})
|
res, err := m.Query.GetResponse(QueryArgs{path, data, opts.Height, opts.Trusted})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ type QueryArgs struct {
|
|||||||
Path string
|
Path string
|
||||||
Data data.Bytes
|
Data data.Bytes
|
||||||
Height uint64
|
Height uint64
|
||||||
Prove bool
|
Trusted bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ABCIRecorder) addCall(call Call) {
|
func (r *ABCIRecorder) addCall(call Call) {
|
||||||
@ -160,14 +160,14 @@ func (r *ABCIRecorder) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *ABCIRecorder) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
func (r *ABCIRecorder) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||||
return r.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions())
|
return r.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
func (r *ABCIRecorder) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||||
res, err := r.Client.ABCIQueryWithOptions(path, data, opts)
|
res, err := r.Client.ABCIQueryWithOptions(path, data, opts)
|
||||||
r.addCall(Call{
|
r.addCall(Call{
|
||||||
Name: "abci_query",
|
Name: "abci_query",
|
||||||
Args: QueryArgs{path, data, opts.Height, opts.Prove},
|
Args: QueryArgs{path, data, opts.Height, opts.Trusted},
|
||||||
Response: res,
|
Response: res,
|
||||||
Error: err,
|
Error: err,
|
||||||
})
|
})
|
||||||
|
@ -51,7 +51,7 @@ func TestABCIMock(t *testing.T) {
|
|||||||
assert.Equal("foobar", err.Error())
|
assert.Equal("foobar", err.Error())
|
||||||
|
|
||||||
// query always returns the response
|
// query always returns the response
|
||||||
query, err := m.ABCIQueryWithOptions("/", nil, client.ABCIQueryOptions{Prove: false})
|
query, err := m.ABCIQueryWithOptions("/", nil, client.ABCIQueryOptions{Trusted: true})
|
||||||
require.Nil(err)
|
require.Nil(err)
|
||||||
require.NotNil(query)
|
require.NotNil(query)
|
||||||
assert.EqualValues(key, query.Key)
|
assert.EqualValues(key, query.Key)
|
||||||
@ -93,7 +93,7 @@ func TestABCIRecorder(t *testing.T) {
|
|||||||
require.Equal(0, len(r.Calls))
|
require.Equal(0, len(r.Calls))
|
||||||
|
|
||||||
r.ABCIInfo()
|
r.ABCIInfo()
|
||||||
r.ABCIQueryWithOptions("path", data.Bytes("data"), client.ABCIQueryOptions{Prove: true})
|
r.ABCIQueryWithOptions("path", data.Bytes("data"), client.ABCIQueryOptions{Trusted: false})
|
||||||
require.Equal(2, len(r.Calls))
|
require.Equal(2, len(r.Calls))
|
||||||
|
|
||||||
info := r.Calls[0]
|
info := r.Calls[0]
|
||||||
@ -116,7 +116,7 @@ func TestABCIRecorder(t *testing.T) {
|
|||||||
require.True(ok)
|
require.True(ok)
|
||||||
assert.Equal("path", qa.Path)
|
assert.Equal("path", qa.Path)
|
||||||
assert.EqualValues("data", qa.Data)
|
assert.EqualValues("data", qa.Data)
|
||||||
assert.True(qa.Prove)
|
assert.False(qa.Trusted)
|
||||||
|
|
||||||
// now add some broadcasts
|
// now add some broadcasts
|
||||||
txs := []types.Tx{{1}, {2}, {3}}
|
txs := []types.Tx{{1}, {2}, {3}}
|
||||||
@ -165,7 +165,7 @@ func TestABCIApp(t *testing.T) {
|
|||||||
assert.True(res.DeliverTx.Code.IsOK())
|
assert.True(res.DeliverTx.Code.IsOK())
|
||||||
|
|
||||||
// check the key
|
// check the key
|
||||||
qres, err := m.ABCIQueryWithOptions("/key", data.Bytes(key), client.ABCIQueryOptions{Prove: false})
|
qres, err := m.ABCIQueryWithOptions("/key", data.Bytes(key), client.ABCIQueryOptions{Trusted: true})
|
||||||
require.Nil(err)
|
require.Nil(err)
|
||||||
assert.EqualValues(value, qres.Value)
|
assert.EqualValues(value, qres.Value)
|
||||||
}
|
}
|
||||||
|
@ -85,11 +85,11 @@ func (c Client) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
func (c Client) ABCIQuery(path string, data data.Bytes) (*ctypes.ResultABCIQuery, error) {
|
||||||
return c.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions())
|
return c.ABCIQueryWithOptions(path, data, client.DefaultABCIQueryOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
func (c Client) ABCIQueryWithOptions(path string, data data.Bytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
|
||||||
return core.ABCIQuery(path, data, opts.Height, opts.Prove)
|
return core.ABCIQuery(path, data, opts.Height, opts.Trusted)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
func (c Client) BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||||
|
@ -141,7 +141,7 @@ func TestAppCalls(t *testing.T) {
|
|||||||
|
|
||||||
// wait before querying
|
// wait before querying
|
||||||
client.WaitForHeight(c, apph, nil)
|
client.WaitForHeight(c, apph, nil)
|
||||||
qres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Prove: false})
|
qres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: true})
|
||||||
if assert.Nil(err) && assert.True(qres.Code.IsOK()) {
|
if assert.Nil(err) && assert.True(qres.Code.IsOK()) {
|
||||||
// assert.Equal(k, data.GetKey()) // only returned for proofs
|
// assert.Equal(k, data.GetKey()) // only returned for proofs
|
||||||
assert.EqualValues(v, qres.Value)
|
assert.EqualValues(v, qres.Value)
|
||||||
@ -189,7 +189,7 @@ func TestAppCalls(t *testing.T) {
|
|||||||
assert.Equal(block.Block.LastCommit, commit2.Commit)
|
assert.Equal(block.Block.LastCommit, commit2.Commit)
|
||||||
|
|
||||||
// and we got a proof that works!
|
// and we got a proof that works!
|
||||||
pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Prove: true})
|
pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: false})
|
||||||
if assert.Nil(err) && assert.True(pres.Code.IsOK()) {
|
if assert.Nil(err) && assert.True(pres.Code.IsOK()) {
|
||||||
proof, err := iavl.ReadProof(pres.Proof)
|
proof, err := iavl.ReadProof(pres.Proof)
|
||||||
if assert.Nil(err) {
|
if assert.Nil(err) {
|
||||||
|
@ -4,10 +4,8 @@ package client
|
|||||||
// than the DefaultABCIQueryOptions.
|
// than the DefaultABCIQueryOptions.
|
||||||
type ABCIQueryOptions struct {
|
type ABCIQueryOptions struct {
|
||||||
Height uint64
|
Height uint64
|
||||||
Prove bool
|
Trusted bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultABCIQueryOptions are latest height (0) and prove equal to true.
|
// DefaultABCIQueryOptions are latest height (0) and prove equal to true.
|
||||||
func DefaultABCIQueryOptions() ABCIQueryOptions {
|
var DefaultABCIQueryOptions = ABCIQueryOptions{Height: 0, Trusted: false}
|
||||||
return ABCIQueryOptions{Height: 0, Prove: true}
|
|
||||||
}
|
|
||||||
|
@ -42,17 +42,17 @@ import (
|
|||||||
// ### Query Parameters
|
// ### Query Parameters
|
||||||
//
|
//
|
||||||
// | Parameter | Type | Default | Required | Description |
|
// | Parameter | Type | Default | Required | Description |
|
||||||
// |-----------+--------+---------+----------+---------------------------------------|
|
// |-----------+--------+---------+----------+------------------------------------------------|
|
||||||
// | path | string | false | false | Path to the data ("/a/b/c") |
|
// | path | string | false | false | Path to the data ("/a/b/c") |
|
||||||
// | data | []byte | false | true | Data |
|
// | data | []byte | false | true | Data |
|
||||||
// | height | uint64 | 0 | false | Height (0 means latest) |
|
// | height | uint64 | 0 | false | Height (0 means latest) |
|
||||||
// | prove | bool | false | false | Include a proof of the data inclusion |
|
// | trusted | bool | false | false | Does not include a proof of the data inclusion |
|
||||||
func ABCIQuery(path string, data data.Bytes, height uint64, prove bool) (*ctypes.ResultABCIQuery, error) {
|
func ABCIQuery(path string, data data.Bytes, height uint64, trusted bool) (*ctypes.ResultABCIQuery, error) {
|
||||||
resQuery, err := proxyAppQuery.QuerySync(abci.RequestQuery{
|
resQuery, err := proxyAppQuery.QuerySync(abci.RequestQuery{
|
||||||
Path: path,
|
Path: path,
|
||||||
Data: data,
|
Data: data,
|
||||||
Height: height,
|
Height: height,
|
||||||
Prove: prove,
|
Prove: !trusted,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user