tendermint send_tx

This commit is contained in:
Jae Kwon
2015-08-14 14:11:11 -07:00
parent 1a27d4dd63
commit 56b195a899
13 changed files with 313 additions and 144 deletions

View File

@ -52,6 +52,9 @@ func (c *ClientHTTP) BlockchainInfo(minHeight int, maxHeight int) (*ctypes.Resul
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultBlockchainInfo)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -77,6 +80,9 @@ func (c *ClientHTTP) BroadcastTx(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultBroadcastTx)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -102,6 +108,9 @@ func (c *ClientHTTP) Call(fromAddress []byte, toAddress []byte, data []byte) (*c
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultCall)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -127,6 +136,9 @@ func (c *ClientHTTP) CallCode(fromAddress []byte, code []byte, data []byte) (*ct
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultCall)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -152,6 +164,9 @@ func (c *ClientHTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, err
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultDumpConsensusState)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -177,6 +192,9 @@ func (c *ClientHTTP) DumpStorage(address []byte) (*ctypes.ResultDumpStorage, err
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultDumpStorage)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -202,6 +220,9 @@ func (c *ClientHTTP) GenPrivAccount() (*ctypes.ResultGenPrivAccount, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGenPrivAccount)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -227,6 +248,9 @@ func (c *ClientHTTP) Genesis() (*ctypes.ResultGenesis, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGenesis)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -252,6 +276,9 @@ func (c *ClientHTTP) GetAccount(address []byte) (*ctypes.ResultGetAccount, error
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGetAccount)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -277,6 +304,9 @@ func (c *ClientHTTP) GetBlock(height int) (*ctypes.ResultGetBlock, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGetBlock)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -302,6 +332,9 @@ func (c *ClientHTTP) GetName(name string) (*ctypes.ResultGetName, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGetName)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -327,6 +360,9 @@ func (c *ClientHTTP) GetStorage(address []byte, key []byte) (*ctypes.ResultGetSt
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGetStorage)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -352,6 +388,9 @@ func (c *ClientHTTP) ListAccounts() (*ctypes.ResultListAccounts, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultListAccounts)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -377,6 +416,9 @@ func (c *ClientHTTP) ListNames() (*ctypes.ResultListNames, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultListNames)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -402,6 +444,9 @@ func (c *ClientHTTP) ListUnconfirmedTxs() (*ctypes.ResultListUnconfirmedTxs, err
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultListUnconfirmedTxs)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -427,6 +472,9 @@ func (c *ClientHTTP) ListValidators() (*ctypes.ResultListValidators, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultListValidators)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -452,6 +500,9 @@ func (c *ClientHTTP) NetInfo() (*ctypes.ResultNetInfo, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultNetInfo)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -477,6 +528,9 @@ func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*acm.PrivAccount) (*ctyp
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultSignTx)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -502,6 +556,9 @@ func (c *ClientHTTP) Status() (*ctypes.ResultStatus, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultStatus)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -524,6 +581,9 @@ func (c *ClientJSON) BlockchainInfo(minHeight int, maxHeight int) (*ctypes.Resul
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultBlockchainInfo)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -546,6 +606,9 @@ func (c *ClientJSON) BroadcastTx(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultBroadcastTx)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -568,6 +631,9 @@ func (c *ClientJSON) Call(fromAddress []byte, toAddress []byte, data []byte) (*c
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultCall)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -590,6 +656,9 @@ func (c *ClientJSON) CallCode(fromAddress []byte, code []byte, data []byte) (*ct
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultCall)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -612,6 +681,9 @@ func (c *ClientJSON) DumpConsensusState() (*ctypes.ResultDumpConsensusState, err
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultDumpConsensusState)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -634,6 +706,9 @@ func (c *ClientJSON) DumpStorage(address []byte) (*ctypes.ResultDumpStorage, err
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultDumpStorage)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -656,6 +731,9 @@ func (c *ClientJSON) GenPrivAccount() (*ctypes.ResultGenPrivAccount, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGenPrivAccount)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -678,6 +756,9 @@ func (c *ClientJSON) Genesis() (*ctypes.ResultGenesis, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGenesis)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -700,6 +781,9 @@ func (c *ClientJSON) GetAccount(address []byte) (*ctypes.ResultGetAccount, error
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGetAccount)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -722,6 +806,9 @@ func (c *ClientJSON) GetBlock(height int) (*ctypes.ResultGetBlock, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGetBlock)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -744,6 +831,9 @@ func (c *ClientJSON) GetName(name string) (*ctypes.ResultGetName, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGetName)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -766,6 +856,9 @@ func (c *ClientJSON) GetStorage(address []byte, key []byte) (*ctypes.ResultGetSt
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultGetStorage)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -788,6 +881,9 @@ func (c *ClientJSON) ListAccounts() (*ctypes.ResultListAccounts, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultListAccounts)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -810,6 +906,9 @@ func (c *ClientJSON) ListNames() (*ctypes.ResultListNames, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultListNames)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -832,6 +931,9 @@ func (c *ClientJSON) ListUnconfirmedTxs() (*ctypes.ResultListUnconfirmedTxs, err
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultListUnconfirmedTxs)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -854,6 +956,9 @@ func (c *ClientJSON) ListValidators() (*ctypes.ResultListValidators, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultListValidators)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -876,6 +981,9 @@ func (c *ClientJSON) NetInfo() (*ctypes.ResultNetInfo, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultNetInfo)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -898,6 +1006,9 @@ func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*acm.PrivAccount) (*ctyp
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultSignTx)
if !ok {
return nil, fmt.Errorf("response result was wrong type")
@ -920,6 +1031,9 @@ func (c *ClientJSON) Status() (*ctypes.ResultStatus, error) {
if err != nil {
return nil, err
}
if response.Result == nil {
return nil, nil
}
result, ok := response.Result.(*ctypes.ResultStatus)
if !ok {
return nil, fmt.Errorf("response result was wrong type")