2015-04-07 11:44:25 -07:00
|
|
|
package core_types
|
2015-03-27 02:25:41 -07:00
|
|
|
|
|
|
|
import (
|
2015-07-19 09:40:55 -07:00
|
|
|
acm "github.com/tendermint/tendermint/account"
|
2015-08-10 20:38:45 -07:00
|
|
|
stypes "github.com/tendermint/tendermint/state/types"
|
2015-04-01 17:30:16 -07:00
|
|
|
"github.com/tendermint/tendermint/types"
|
2015-10-22 17:39:06 -07:00
|
|
|
"github.com/tendermint/go-wire"
|
2015-03-27 02:25:41 -07:00
|
|
|
)
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultGetStorage struct {
|
2015-05-01 17:26:49 -07:00
|
|
|
Key []byte `json:"key"`
|
|
|
|
Value []byte `json:"value"`
|
2015-03-31 04:53:34 -07:00
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultCall struct {
|
2015-05-01 17:26:49 -07:00
|
|
|
Return []byte `json:"return"`
|
2015-06-25 20:28:34 -07:00
|
|
|
GasUsed int64 `json:"gas_used"`
|
2015-03-31 04:53:34 -07:00
|
|
|
// TODO ...
|
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultListAccounts struct {
|
2015-07-19 09:40:55 -07:00
|
|
|
BlockHeight int `json:"block_height"`
|
|
|
|
Accounts []*acm.Account `json:"accounts"`
|
2015-03-27 02:25:41 -07:00
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultDumpStorage struct {
|
|
|
|
StorageRoot []byte `json:"storage_root"`
|
|
|
|
StorageItems []StorageItem `json:"storage_items"`
|
|
|
|
}
|
|
|
|
|
2015-03-31 14:08:21 -07:00
|
|
|
type StorageItem struct {
|
2015-05-01 17:26:49 -07:00
|
|
|
Key []byte `json:"key"`
|
|
|
|
Value []byte `json:"value"`
|
2015-03-31 14:08:21 -07:00
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultBlockchainInfo struct {
|
2015-06-25 20:28:34 -07:00
|
|
|
LastHeight int `json:"last_height"`
|
2015-05-01 17:26:49 -07:00
|
|
|
BlockMetas []*types.BlockMeta `json:"block_metas"`
|
2015-03-27 02:25:41 -07:00
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultGetBlock struct {
|
2015-05-01 17:26:49 -07:00
|
|
|
BlockMeta *types.BlockMeta `json:"block_meta"`
|
|
|
|
Block *types.Block `json:"block"`
|
2015-03-27 02:25:41 -07:00
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultStatus struct {
|
2015-07-10 08:50:58 -07:00
|
|
|
NodeInfo *types.NodeInfo `json:"node_info"`
|
|
|
|
GenesisHash []byte `json:"genesis_hash"`
|
2015-07-19 09:40:55 -07:00
|
|
|
PubKey acm.PubKey `json:"pub_key"`
|
2015-07-10 08:50:58 -07:00
|
|
|
LatestBlockHash []byte `json:"latest_block_hash"`
|
|
|
|
LatestBlockHeight int `json:"latest_block_height"`
|
|
|
|
LatestBlockTime int64 `json:"latest_block_time"` // nano
|
2015-03-27 02:25:41 -07:00
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultNetInfo struct {
|
2015-05-01 17:26:49 -07:00
|
|
|
Listening bool `json:"listening"`
|
|
|
|
Listeners []string `json:"listeners"`
|
|
|
|
Peers []Peer `json:"peers"`
|
2015-04-17 18:22:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
type Peer struct {
|
2015-05-04 18:24:10 -07:00
|
|
|
types.NodeInfo `json:"node_info"`
|
2015-05-01 17:26:49 -07:00
|
|
|
IsOutbound bool `json:"is_outbound"`
|
2015-03-27 02:25:41 -07:00
|
|
|
}
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultListValidators struct {
|
|
|
|
BlockHeight int `json:"block_height"`
|
|
|
|
BondedValidators []*types.Validator `json:"bonded_validators"`
|
|
|
|
UnbondingValidators []*types.Validator `json:"unbonding_validators"`
|
2015-03-27 02:25:41 -07:00
|
|
|
}
|
2015-04-20 20:39:42 -07:00
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultDumpConsensusState struct {
|
2015-05-01 17:26:49 -07:00
|
|
|
RoundState string `json:"round_state"`
|
|
|
|
PeerRoundStates []string `json:"peer_round_states"`
|
2015-04-20 20:39:42 -07:00
|
|
|
}
|
2015-05-22 14:03:22 -07:00
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultListNames struct {
|
2015-06-25 20:28:34 -07:00
|
|
|
BlockHeight int `json:"block_height"`
|
2015-05-30 08:13:09 -07:00
|
|
|
Names []*types.NameRegEntry `json:"names"`
|
2015-05-22 14:03:22 -07:00
|
|
|
}
|
2015-07-23 17:06:38 -07:00
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type ResultGenPrivAccount struct {
|
|
|
|
PrivAccount *acm.PrivAccount `json:"priv_account"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResultGetAccount struct {
|
|
|
|
Account *acm.Account `json:"account"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResultBroadcastTx struct {
|
|
|
|
Receipt Receipt `json:"receipt"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Receipt struct {
|
|
|
|
TxHash []byte `json:"tx_hash"`
|
|
|
|
CreatesContract uint8 `json:"creates_contract"`
|
|
|
|
ContractAddr []byte `json:"contract_addr"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResultListUnconfirmedTxs struct {
|
2015-09-25 09:55:59 -07:00
|
|
|
N int `json:"n_txs"`
|
2015-08-10 20:38:45 -07:00
|
|
|
Txs []types.Tx `json:"txs"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResultGetName struct {
|
|
|
|
Entry *types.NameRegEntry `json:"entry"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResultGenesis struct {
|
|
|
|
Genesis *stypes.GenesisDoc `json:"genesis"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResultSignTx struct {
|
|
|
|
Tx types.Tx `json:"tx"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResultEvent struct {
|
|
|
|
Event string `json:"event"`
|
|
|
|
Data types.EventData `json:"data"`
|
|
|
|
}
|
|
|
|
|
2015-07-23 17:06:38 -07:00
|
|
|
//----------------------------------------
|
2015-08-10 20:38:45 -07:00
|
|
|
// response & result types
|
2015-07-23 17:06:38 -07:00
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
type Response struct {
|
|
|
|
JSONRPC string `json:"jsonrpc"`
|
2015-08-18 10:51:55 -07:00
|
|
|
ID string `json:"id"`
|
2015-08-10 20:38:45 -07:00
|
|
|
Result Result `json:"result"`
|
|
|
|
Error string `json:"error"`
|
2015-07-23 17:06:38 -07:00
|
|
|
}
|
2015-08-10 20:38:45 -07:00
|
|
|
|
|
|
|
const (
|
|
|
|
ResultTypeGetStorage = byte(0x01)
|
|
|
|
ResultTypeCall = byte(0x02)
|
|
|
|
ResultTypeListAccounts = byte(0x03)
|
|
|
|
ResultTypeDumpStorage = byte(0x04)
|
|
|
|
ResultTypeBlockchainInfo = byte(0x05)
|
|
|
|
ResultTypeGetBlock = byte(0x06)
|
|
|
|
ResultTypeStatus = byte(0x07)
|
|
|
|
ResultTypeNetInfo = byte(0x08)
|
|
|
|
ResultTypeListValidators = byte(0x09)
|
|
|
|
ResultTypeDumpConsensusState = byte(0x0A)
|
|
|
|
ResultTypeListNames = byte(0x0B)
|
2015-08-10 21:04:22 -07:00
|
|
|
ResultTypeGenPrivAccount = byte(0x0C)
|
|
|
|
ResultTypeGetAccount = byte(0x0D)
|
|
|
|
ResultTypeBroadcastTx = byte(0x0E)
|
|
|
|
ResultTypeListUnconfirmedTxs = byte(0x0F)
|
|
|
|
ResultTypeGetName = byte(0x10)
|
|
|
|
ResultTypeGenesis = byte(0x11)
|
|
|
|
ResultTypeSignTx = byte(0x12)
|
2015-08-10 20:38:45 -07:00
|
|
|
ResultTypeEvent = byte(0x13) // so websockets can respond to rpc functions
|
|
|
|
)
|
|
|
|
|
|
|
|
type Result interface{}
|
|
|
|
|
|
|
|
// for wire.readReflect
|
|
|
|
var _ = wire.RegisterInterface(
|
|
|
|
struct{ Result }{},
|
|
|
|
wire.ConcreteType{&ResultGetStorage{}, ResultTypeGetStorage},
|
|
|
|
wire.ConcreteType{&ResultCall{}, ResultTypeCall},
|
|
|
|
wire.ConcreteType{&ResultListAccounts{}, ResultTypeListAccounts},
|
|
|
|
wire.ConcreteType{&ResultDumpStorage{}, ResultTypeDumpStorage},
|
|
|
|
wire.ConcreteType{&ResultBlockchainInfo{}, ResultTypeBlockchainInfo},
|
|
|
|
wire.ConcreteType{&ResultGetBlock{}, ResultTypeGetBlock},
|
|
|
|
wire.ConcreteType{&ResultStatus{}, ResultTypeStatus},
|
|
|
|
wire.ConcreteType{&ResultNetInfo{}, ResultTypeNetInfo},
|
|
|
|
wire.ConcreteType{&ResultListValidators{}, ResultTypeListValidators},
|
|
|
|
wire.ConcreteType{&ResultDumpConsensusState{}, ResultTypeDumpConsensusState},
|
|
|
|
wire.ConcreteType{&ResultListNames{}, ResultTypeListNames},
|
|
|
|
wire.ConcreteType{&ResultGenPrivAccount{}, ResultTypeGenPrivAccount},
|
|
|
|
wire.ConcreteType{&ResultGetAccount{}, ResultTypeGetAccount},
|
|
|
|
wire.ConcreteType{&ResultBroadcastTx{}, ResultTypeBroadcastTx},
|
|
|
|
wire.ConcreteType{&ResultListUnconfirmedTxs{}, ResultTypeListUnconfirmedTxs},
|
|
|
|
wire.ConcreteType{&ResultGetName{}, ResultTypeGetName},
|
|
|
|
wire.ConcreteType{&ResultGenesis{}, ResultTypeGenesis},
|
|
|
|
wire.ConcreteType{&ResultSignTx{}, ResultTypeSignTx},
|
|
|
|
wire.ConcreteType{&ResultEvent{}, ResultTypeEvent},
|
|
|
|
)
|