add client methods

This commit is contained in:
Anton Kaliaev
2017-11-29 13:42:11 -06:00
parent 1e19860585
commit acbc0717d4
6 changed files with 67 additions and 4 deletions

View File

@ -163,17 +163,30 @@ func (c *HTTP) Commit(height *int) (*ctypes.ResultCommit, error) {
func (c *HTTP) Tx(hash []byte, prove bool) (*ctypes.ResultTx, error) {
result := new(ctypes.ResultTx)
query := map[string]interface{}{
params := map[string]interface{}{
"hash": hash,
"prove": prove,
}
_, err := c.rpc.Call("tx", query, result)
_, err := c.rpc.Call("tx", params, result)
if err != nil {
return nil, errors.Wrap(err, "Tx")
}
return result, nil
}
func (c *HTTP) TxSearch(query string, prove bool) ([]*ctypes.ResultTx, error) {
results := new([]*ctypes.ResultTx)
params := map[string]interface{}{
"query": query,
"prove": prove,
}
_, err := c.rpc.Call("tx_search", params, results)
if err != nil {
return nil, errors.Wrap(err, "TxSearch")
}
return *results, nil
}
func (c *HTTP) Validators(height *int) (*ctypes.ResultValidators, error) {
result := new(ctypes.ResultValidators)
_, err := c.rpc.Call("validators", map[string]interface{}{"height": height}, result)