mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 04:01:40 +00:00
Merge branch 'rpc_jae' into develop
Conflicts: node/node.go rpc/core/accounts.go rpc/core_client/client.go rpc/handlers.go rpc/http_server.go rpc/test/helpers.go rpc/test/http_rpc_test.go rpc/test/json_rpc_test.go
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
// File generated by github.com/ebuchman/rpc-gen
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
@ -11,14 +13,15 @@ import (
|
||||
)
|
||||
|
||||
type Client interface {
|
||||
BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInfo, error)
|
||||
BlockchainInfo(minHeight uint, maxHeight uint) (*core.ResponseBlockchainInfo, error)
|
||||
BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error)
|
||||
Call(address []byte) (*core.ResponseCall, error)
|
||||
Call(address []byte, data []byte) (*core.ResponseCall, error)
|
||||
CallCode(code []byte, data []byte) (*core.ResponseCall, error)
|
||||
DumpStorage(addr []byte) (*core.ResponseDumpStorage, error)
|
||||
GenPrivAccount() (*core.ResponseGenPrivAccount, error)
|
||||
GetAccount(address []byte) (*core.ResponseGetAccount, error)
|
||||
GetBlock(height uint) (*core.ResponseGetBlock, error)
|
||||
GetStorage(address []byte) (*core.ResponseGetStorage, error)
|
||||
GetStorage(address []byte, key []byte) (*core.ResponseGetStorage, error)
|
||||
ListAccounts() (*core.ResponseListAccounts, error)
|
||||
ListValidators() (*core.ResponseListValidators, error)
|
||||
NetInfo() (*core.ResponseNetInfo, error)
|
||||
@ -26,12 +29,12 @@ type Client interface {
|
||||
Status() (*core.ResponseStatus, error)
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInfo, error) {
|
||||
values, err := argsToURLValues([]string{"minHeight"}, minHeight)
|
||||
func (c *ClientHTTP) BlockchainInfo(minHeight uint, maxHeight uint) (*core.ResponseBlockchainInfo, error) {
|
||||
values, err := argsToURLValues([]string{"minHeight", "maxHeight"}, minHeight, maxHeight)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"blockchain_info", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["BlockchainInfo"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -61,7 +64,7 @@ func (c *ClientHTTP) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"broadcast_tx", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["BroadcastTx"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -86,12 +89,42 @@ func (c *ClientHTTP) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error)
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) Call(address []byte) (*core.ResponseCall, error) {
|
||||
values, err := argsToURLValues([]string{"address"}, address)
|
||||
func (c *ClientHTTP) Call(address []byte, data []byte) (*core.ResponseCall, error) {
|
||||
values, err := argsToURLValues([]string{"address", "data"}, address, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"call", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["Call"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var response struct {
|
||||
Result *core.ResponseCall `json:"result"`
|
||||
Error string `json:"error"`
|
||||
Id string `json:"id"`
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
}
|
||||
binary.ReadJSON(&response, body, &err)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Error != "" {
|
||||
return nil, fmt.Errorf(response.Error)
|
||||
}
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) CallCode(code []byte, data []byte) (*core.ResponseCall, error) {
|
||||
values, err := argsToURLValues([]string{"code", "data"}, code, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["CallCode"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -121,7 +154,7 @@ func (c *ClientHTTP) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"dump_storage", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["DumpStorage"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -147,11 +180,11 @@ func (c *ClientHTTP) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error)
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) GenPrivAccount() (*core.ResponseGenPrivAccount, error) {
|
||||
values, err := argsToURLValues(nil, nil)
|
||||
values, err := argsToURLValues(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"gen_priv_account", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["GenPrivAccount"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -181,7 +214,7 @@ func (c *ClientHTTP) GetAccount(address []byte) (*core.ResponseGetAccount, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"get_account", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["GetAccount"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -211,7 +244,7 @@ func (c *ClientHTTP) GetBlock(height uint) (*core.ResponseGetBlock, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"get_block", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["GetBlock"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -236,12 +269,12 @@ func (c *ClientHTTP) GetBlock(height uint) (*core.ResponseGetBlock, error) {
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) GetStorage(address []byte) (*core.ResponseGetStorage, error) {
|
||||
values, err := argsToURLValues([]string{"address"}, address)
|
||||
func (c *ClientHTTP) GetStorage(address []byte, key []byte) (*core.ResponseGetStorage, error) {
|
||||
values, err := argsToURLValues([]string{"address", "key"}, address, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"get_storage", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["GetStorage"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -267,11 +300,11 @@ func (c *ClientHTTP) GetStorage(address []byte) (*core.ResponseGetStorage, error
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) ListAccounts() (*core.ResponseListAccounts, error) {
|
||||
values, err := argsToURLValues(nil, nil)
|
||||
values, err := argsToURLValues(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"list_accounts", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["ListAccounts"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -297,11 +330,11 @@ func (c *ClientHTTP) ListAccounts() (*core.ResponseListAccounts, error) {
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) ListValidators() (*core.ResponseListValidators, error) {
|
||||
values, err := argsToURLValues(nil, nil)
|
||||
values, err := argsToURLValues(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"list_validators", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["ListValidators"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -327,11 +360,11 @@ func (c *ClientHTTP) ListValidators() (*core.ResponseListValidators, error) {
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) NetInfo() (*core.ResponseNetInfo, error) {
|
||||
values, err := argsToURLValues(nil, nil)
|
||||
values, err := argsToURLValues(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"net_info", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["NetInfo"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -357,11 +390,11 @@ func (c *ClientHTTP) NetInfo() (*core.ResponseNetInfo, error) {
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) {
|
||||
values, err := argsToURLValues([]string{"tx", "privAccounts"}, tx, privAccounts)
|
||||
values, err := argsToURLValues([]string{"tx", "priv_accounts"}, tx, privAccounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"sign_tx", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["SignTx"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -387,11 +420,11 @@ func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) Status() (*core.ResponseStatus, error) {
|
||||
values, err := argsToURLValues(nil, nil)
|
||||
values, err := argsToURLValues(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := http.PostForm(c.addr+"status", values)
|
||||
resp, err := http.PostForm(c.addr+reverseFuncMap["Status"], values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -416,11 +449,11 @@ func (c *ClientHTTP) Status() (*core.ResponseStatus, error) {
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientJSON) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInfo, error) {
|
||||
func (c *ClientJSON) BlockchainInfo(minHeight uint, maxHeight uint) (*core.ResponseBlockchainInfo, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "blockchain_info",
|
||||
Params: []interface{}{minHeight},
|
||||
Method: reverseFuncMap["BlockchainInfo"],
|
||||
Params: []interface{}{minHeight, maxHeight},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
@ -446,7 +479,7 @@ func (c *ClientJSON) BlockchainInfo(minHeight uint) (*core.ResponseBlockchainInf
|
||||
func (c *ClientJSON) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "broadcast_tx",
|
||||
Method: reverseFuncMap["BroadcastTx"],
|
||||
Params: []interface{}{tx},
|
||||
Id: 0,
|
||||
}
|
||||
@ -470,11 +503,38 @@ func (c *ClientJSON) BroadcastTx(tx types.Tx) (*core.ResponseBroadcastTx, error)
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientJSON) Call(address []byte) (*core.ResponseCall, error) {
|
||||
func (c *ClientJSON) Call(address []byte, data []byte) (*core.ResponseCall, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "call",
|
||||
Params: []interface{}{address},
|
||||
Method: reverseFuncMap["Call"],
|
||||
Params: []interface{}{address, data},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var response struct {
|
||||
Result *core.ResponseCall `json:"result"`
|
||||
Error string `json:"error"`
|
||||
Id string `json:"id"`
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
}
|
||||
binary.ReadJSON(&response, body, &err)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Error != "" {
|
||||
return nil, fmt.Errorf(response.Error)
|
||||
}
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientJSON) CallCode(code []byte, data []byte) (*core.ResponseCall, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: reverseFuncMap["CallCode"],
|
||||
Params: []interface{}{code, data},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
@ -500,7 +560,7 @@ func (c *ClientJSON) Call(address []byte) (*core.ResponseCall, error) {
|
||||
func (c *ClientJSON) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "dump_storage",
|
||||
Method: reverseFuncMap["DumpStorage"],
|
||||
Params: []interface{}{addr},
|
||||
Id: 0,
|
||||
}
|
||||
@ -527,8 +587,8 @@ func (c *ClientJSON) DumpStorage(addr []byte) (*core.ResponseDumpStorage, error)
|
||||
func (c *ClientJSON) GenPrivAccount() (*core.ResponseGenPrivAccount, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "gen_priv_account",
|
||||
Params: []interface{}{nil},
|
||||
Method: reverseFuncMap["GenPrivAccount"],
|
||||
Params: []interface{}{},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
@ -554,7 +614,7 @@ func (c *ClientJSON) GenPrivAccount() (*core.ResponseGenPrivAccount, error) {
|
||||
func (c *ClientJSON) GetAccount(address []byte) (*core.ResponseGetAccount, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "get_account",
|
||||
Method: reverseFuncMap["GetAccount"],
|
||||
Params: []interface{}{address},
|
||||
Id: 0,
|
||||
}
|
||||
@ -581,7 +641,7 @@ func (c *ClientJSON) GetAccount(address []byte) (*core.ResponseGetAccount, error
|
||||
func (c *ClientJSON) GetBlock(height uint) (*core.ResponseGetBlock, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "get_block",
|
||||
Method: reverseFuncMap["GetBlock"],
|
||||
Params: []interface{}{height},
|
||||
Id: 0,
|
||||
}
|
||||
@ -605,11 +665,11 @@ func (c *ClientJSON) GetBlock(height uint) (*core.ResponseGetBlock, error) {
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientJSON) GetStorage(address []byte) (*core.ResponseGetStorage, error) {
|
||||
func (c *ClientJSON) GetStorage(address []byte, key []byte) (*core.ResponseGetStorage, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "get_storage",
|
||||
Params: []interface{}{address},
|
||||
Method: reverseFuncMap["GetStorage"],
|
||||
Params: []interface{}{address, key},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
@ -635,8 +695,8 @@ func (c *ClientJSON) GetStorage(address []byte) (*core.ResponseGetStorage, error
|
||||
func (c *ClientJSON) ListAccounts() (*core.ResponseListAccounts, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "list_accounts",
|
||||
Params: []interface{}{nil},
|
||||
Method: reverseFuncMap["ListAccounts"],
|
||||
Params: []interface{}{},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
@ -662,8 +722,8 @@ func (c *ClientJSON) ListAccounts() (*core.ResponseListAccounts, error) {
|
||||
func (c *ClientJSON) ListValidators() (*core.ResponseListValidators, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "list_validators",
|
||||
Params: []interface{}{nil},
|
||||
Method: reverseFuncMap["ListValidators"],
|
||||
Params: []interface{}{},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
@ -689,8 +749,8 @@ func (c *ClientJSON) ListValidators() (*core.ResponseListValidators, error) {
|
||||
func (c *ClientJSON) NetInfo() (*core.ResponseNetInfo, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "net_info",
|
||||
Params: []interface{}{nil},
|
||||
Method: reverseFuncMap["NetInfo"],
|
||||
Params: []interface{}{},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
@ -716,7 +776,7 @@ func (c *ClientJSON) NetInfo() (*core.ResponseNetInfo, error) {
|
||||
func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "sign_tx",
|
||||
Method: reverseFuncMap["SignTx"],
|
||||
Params: []interface{}{tx, privAccounts},
|
||||
Id: 0,
|
||||
}
|
||||
@ -743,8 +803,8 @@ func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*
|
||||
func (c *ClientJSON) Status() (*core.ResponseStatus, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: "status",
|
||||
Params: []interface{}{nil},
|
||||
Method: reverseFuncMap["Status"],
|
||||
Params: []interface{}{},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
|
Reference in New Issue
Block a user