rpc: remove unecessary response wrappers

This commit is contained in:
Ethan Buchman
2015-06-01 13:51:03 -04:00
parent 293aa31f64
commit ec282d3e3d
7 changed files with 76 additions and 97 deletions

View File

@ -7,11 +7,11 @@ import (
ctypes "github.com/tendermint/tendermint/rpc/core/types"
)
func GenPrivAccount() (*ctypes.ResponseGenPrivAccount, error) {
return &ctypes.ResponseGenPrivAccount{acm.GenPrivAccount()}, nil
func GenPrivAccount() (*acm.PrivAccount, error) {
return acm.GenPrivAccount(), nil
}
func GetAccount(address []byte) (*ctypes.ResponseGetAccount, error) {
func GetAccount(address []byte) (*acm.Account, error) {
cache := mempoolReactor.Mempool.GetCache()
account := cache.GetAccount(address)
if account == nil {
@ -24,7 +24,7 @@ func GetAccount(address []byte) (*ctypes.ResponseGetAccount, error) {
StorageRoot: nil,
}
}
return &ctypes.ResponseGetAccount{account}, nil
return account, nil
}
func GetStorage(address, key []byte) (*ctypes.ResponseGetStorage, error) {

View File

@ -9,9 +9,8 @@ import (
//-----------------------------------------------------------------------------
// pass pointer?
// Note: tx must be signed
func BroadcastTx(tx types.Tx) (*ctypes.ResponseBroadcastTx, error) {
func BroadcastTx(tx types.Tx) (*ctypes.Receipt, error) {
err := mempoolReactor.BroadcastTx(tx)
if err != nil {
return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
@ -27,10 +26,9 @@ func BroadcastTx(tx types.Tx) (*ctypes.ResponseBroadcastTx, error) {
contractAddr = state.NewContractAddress(callTx.Input.Address, uint64(callTx.Input.Sequence))
}
}
return &ctypes.ResponseBroadcastTx{ctypes.Receipt{txHash, createsContract, contractAddr}}, nil
return &ctypes.Receipt{txHash, createsContract, contractAddr}, nil
}
func ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) {
txs := mempoolReactor.Mempool.GetProposalTxs()
return &ctypes.ResponseListUnconfirmedTxs{txs}, nil
func ListUnconfirmedTxs() ([]types.Tx, error) {
return mempoolReactor.Mempool.GetProposalTxs(), nil
}

View File

@ -78,7 +78,7 @@ func CallCode(code, data []byte) (*ctypes.ResponseCall, error) {
//-----------------------------------------------------------------------------
func SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*ctypes.ResponseSignTx, error) {
func SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error) {
// more checks?
for i, privAccount := range privAccounts {
@ -113,5 +113,5 @@ func SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*ctypes.ResponseS
rebondTx := tx.(*types.RebondTx)
rebondTx.Signature = privAccounts[0].Sign(config.GetString("chain_id"), rebondTx).(account.SignatureEd25519)
}
return &ctypes.ResponseSignTx{tx}, nil
return tx, nil
}

View File

@ -6,14 +6,6 @@ import (
"github.com/tendermint/tendermint/types"
)
type ResponseGenPrivAccount struct {
PrivAccount *account.PrivAccount `json:"priv_account"`
}
type ResponseGetAccount struct {
Account *account.Account `json:"account"`
}
type ResponseGetStorage struct {
Key []byte `json:"key"`
Value []byte `json:"value"`
@ -50,14 +42,6 @@ type ResponseGetBlock struct {
Block *types.Block `json:"block"`
}
type ResponseBroadcastTx struct {
Receipt Receipt `json:"receipt"`
}
type ResponseListUnconfirmedTxs struct {
Txs []types.Tx `json:"txs"`
}
type Receipt struct {
TxHash []byte `json:"tx_hash"`
CreatesContract uint8 `json:"creates_contract"`
@ -86,10 +70,6 @@ type Peer struct {
IsOutbound bool `json:"is_outbound"`
}
type ResponseSignTx struct {
Tx types.Tx `json:"tx"`
}
type ResponseListValidators struct {
BlockHeight uint `json:"block_height"`
BondedValidators []*sm.Validator `json:"bonded_validators"`