-
Notifications
You must be signed in to change notification settings - Fork 14
/
routes.go
145 lines (114 loc) · 4.41 KB
/
routes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package core
import (
rpc "github.com/tendermint/go-rpc/server"
"github.com/tendermint/go-rpc/types"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
)
// TODO: better system than "unsafe" prefix
var Routes = map[string]*rpc.RPCFunc{
// subscribe/unsubscribe are reserved for websocket events.
"subscribe": rpc.NewWSRPCFunc(SubscribeResult, "event"),
"unsubscribe": rpc.NewWSRPCFunc(UnsubscribeResult, "event"),
// info API
"status": rpc.NewRPCFunc(StatusResult, ""),
"net_info": rpc.NewRPCFunc(NetInfoResult, ""),
"blockchain": rpc.NewRPCFunc(BlockchainInfoResult, "minHeight,maxHeight"),
"genesis": rpc.NewRPCFunc(GenesisResult, ""),
"block": rpc.NewRPCFunc(BlockResult, "height"),
"commit": rpc.NewRPCFunc(CommitResult, "height"),
"tx": rpc.NewRPCFunc(TxResult, "hash,prove"),
"validators": rpc.NewRPCFunc(ValidatorsResult, ""),
"dump_consensus_state": rpc.NewRPCFunc(DumpConsensusStateResult, ""),
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""),
"num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxsResult, ""),
// broadcast API
"broadcast_tx_commit": rpc.NewRPCFunc(BroadcastTxCommitResult, "tx"),
"broadcast_tx_sync": rpc.NewRPCFunc(BroadcastTxSyncResult, "tx"),
"broadcast_tx_async": rpc.NewRPCFunc(BroadcastTxAsyncResult, "tx"),
// abci API
"abci_query": rpc.NewRPCFunc(ABCIQueryResult, "path,data,prove"),
"abci_info": rpc.NewRPCFunc(ABCIInfoResult, ""),
// control API
"dial_seeds": rpc.NewRPCFunc(UnsafeDialSeedsResult, "seeds"),
"unsafe_flush_mempool": rpc.NewRPCFunc(UnsafeFlushMempool, ""),
"unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"),
// profiler API
"unsafe_start_cpu_profiler": rpc.NewRPCFunc(UnsafeStartCPUProfilerResult, "filename"),
"unsafe_stop_cpu_profiler": rpc.NewRPCFunc(UnsafeStopCPUProfilerResult, ""),
"unsafe_write_heap_profile": rpc.NewRPCFunc(UnsafeWriteHeapProfileResult, "filename"),
}
func SubscribeResult(wsCtx rpctypes.WSRPCContext, event string) (ctypes.TMResult, error) {
return Subscribe(wsCtx, event)
}
func UnsubscribeResult(wsCtx rpctypes.WSRPCContext, event string) (ctypes.TMResult, error) {
return Unsubscribe(wsCtx, event)
}
func StatusResult() (ctypes.TMResult, error) {
return Status()
}
func NetInfoResult() (ctypes.TMResult, error) {
return NetInfo()
}
func UnsafeDialSeedsResult(seeds []string) (ctypes.TMResult, error) {
return UnsafeDialSeeds(seeds)
}
func BlockchainInfoResult(min, max int) (ctypes.TMResult, error) {
return BlockchainInfo(min, max)
}
func GenesisResult() (ctypes.TMResult, error) {
return Genesis()
}
func BlockResult(height int) (ctypes.TMResult, error) {
return Block(height)
}
func CommitResult(height int) (ctypes.TMResult, error) {
return Commit(height)
}
func ValidatorsResult() (ctypes.TMResult, error) {
return Validators()
}
func DumpConsensusStateResult() (ctypes.TMResult, error) {
return DumpConsensusState()
}
func UnconfirmedTxsResult() (ctypes.TMResult, error) {
return UnconfirmedTxs()
}
func NumUnconfirmedTxsResult() (ctypes.TMResult, error) {
return NumUnconfirmedTxs()
}
// Tx allow user to query the transaction results. `nil` could mean the
// transaction is in the mempool, invalidated, or was not send in the first
// place.
func TxResult(hash []byte, prove bool) (ctypes.TMResult, error) {
return Tx(hash, prove)
}
func BroadcastTxCommitResult(tx []byte) (ctypes.TMResult, error) {
return BroadcastTxCommit(tx)
}
func BroadcastTxSyncResult(tx []byte) (ctypes.TMResult, error) {
return BroadcastTxSync(tx)
}
func BroadcastTxAsyncResult(tx []byte) (ctypes.TMResult, error) {
return BroadcastTxAsync(tx)
}
func ABCIQueryResult(path string, data []byte, prove bool) (ctypes.TMResult, error) {
return ABCIQuery(path, data, prove)
}
func ABCIInfoResult() (ctypes.TMResult, error) {
return ABCIInfo()
}
func UnsafeFlushMempoolResult() (ctypes.TMResult, error) {
return UnsafeFlushMempool()
}
func UnsafeSetConfigResult(typ, key, value string) (ctypes.TMResult, error) {
return UnsafeSetConfig(typ, key, value)
}
func UnsafeStartCPUProfilerResult(filename string) (ctypes.TMResult, error) {
return UnsafeStartCPUProfiler(filename)
}
func UnsafeStopCPUProfilerResult() (ctypes.TMResult, error) {
return UnsafeStopCPUProfiler()
}
func UnsafeWriteHeapProfileResult(filename string) (ctypes.TMResult, error) {
return UnsafeWriteHeapProfile(filename)
}