You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
4.4 KiB

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