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.

60 lines
2.8 KiB

  1. package core
  2. import (
  3. rpc "github.com/tendermint/tendermint/rpc/jsonrpc/server"
  4. )
  5. // TODO: better system than "unsafe" prefix
  6. type RoutesMap map[string]*rpc.RPCFunc
  7. // Routes is a map of available routes.
  8. func (env *Environment) GetRoutes() RoutesMap {
  9. return RoutesMap{
  10. // subscribe/unsubscribe are reserved for websocket events.
  11. "subscribe": rpc.NewWSRPCFunc(env.Subscribe, "query"),
  12. "unsubscribe": rpc.NewWSRPCFunc(env.Unsubscribe, "query"),
  13. "unsubscribe_all": rpc.NewWSRPCFunc(env.UnsubscribeAll, ""),
  14. // info API
  15. "health": rpc.NewRPCFunc(env.Health, "", false),
  16. "status": rpc.NewRPCFunc(env.Status, "", false),
  17. "net_info": rpc.NewRPCFunc(env.NetInfo, "", false),
  18. "blockchain": rpc.NewRPCFunc(env.BlockchainInfo, "minHeight,maxHeight", true),
  19. "genesis": rpc.NewRPCFunc(env.Genesis, "", true),
  20. "genesis_chunked": rpc.NewRPCFunc(env.GenesisChunked, "chunk", true),
  21. "block": rpc.NewRPCFunc(env.Block, "height", true),
  22. "block_by_hash": rpc.NewRPCFunc(env.BlockByHash, "hash", true),
  23. "block_results": rpc.NewRPCFunc(env.BlockResults, "height", true),
  24. "commit": rpc.NewRPCFunc(env.Commit, "height", true),
  25. "check_tx": rpc.NewRPCFunc(env.CheckTx, "tx", true),
  26. "remove_tx": rpc.NewRPCFunc(env.RemoveTx, "txkey", false),
  27. "tx": rpc.NewRPCFunc(env.Tx, "hash,prove", true),
  28. "tx_search": rpc.NewRPCFunc(env.TxSearch, "query,prove,page,per_page,order_by", false),
  29. "block_search": rpc.NewRPCFunc(env.BlockSearch, "query,page,per_page,order_by", false),
  30. "validators": rpc.NewRPCFunc(env.Validators, "height,page,per_page", true),
  31. "dump_consensus_state": rpc.NewRPCFunc(env.DumpConsensusState, "", false),
  32. "consensus_state": rpc.NewRPCFunc(env.GetConsensusState, "", false),
  33. "consensus_params": rpc.NewRPCFunc(env.ConsensusParams, "height", true),
  34. "unconfirmed_txs": rpc.NewRPCFunc(env.UnconfirmedTxs, "limit", false),
  35. "num_unconfirmed_txs": rpc.NewRPCFunc(env.NumUnconfirmedTxs, "", false),
  36. // tx broadcast API
  37. "broadcast_tx_commit": rpc.NewRPCFunc(env.BroadcastTxCommit, "tx", false),
  38. "broadcast_tx_sync": rpc.NewRPCFunc(env.BroadcastTxSync, "tx", false),
  39. "broadcast_tx_async": rpc.NewRPCFunc(env.BroadcastTxAsync, "tx", false),
  40. // abci API
  41. "abci_query": rpc.NewRPCFunc(env.ABCIQuery, "path,data,height,prove", false),
  42. "abci_info": rpc.NewRPCFunc(env.ABCIInfo, "", true),
  43. // evidence API
  44. "broadcast_evidence": rpc.NewRPCFunc(env.BroadcastEvidence, "evidence", false),
  45. }
  46. }
  47. // AddUnsafeRoutes adds unsafe routes.
  48. func (env *Environment) AddUnsafe(routes RoutesMap) {
  49. // control API
  50. routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(env.UnsafeFlushMempool, "", false)
  51. }