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.

64 lines
3.1 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. "header": rpc.NewRPCFunc(env.Header, "height", true),
  22. "header_by_hash": rpc.NewRPCFunc(env.HeaderByHash, "hash", true),
  23. "block": rpc.NewRPCFunc(env.Block, "height", true),
  24. "block_by_hash": rpc.NewRPCFunc(env.BlockByHash, "hash", true),
  25. "block_results": rpc.NewRPCFunc(env.BlockResults, "height", true),
  26. "commit": rpc.NewRPCFunc(env.Commit, "height", true),
  27. "check_tx": rpc.NewRPCFunc(env.CheckTx, "tx", true),
  28. "remove_tx": rpc.NewRPCFunc(env.RemoveTx, "txkey", false),
  29. "tx": rpc.NewRPCFunc(env.Tx, "hash,prove", true),
  30. "tx_search": rpc.NewRPCFunc(env.TxSearch, "query,prove,page,per_page,order_by", false),
  31. "block_search": rpc.NewRPCFunc(env.BlockSearch, "query,page,per_page,order_by", false),
  32. "validators": rpc.NewRPCFunc(env.Validators, "height,page,per_page", true),
  33. "dump_consensus_state": rpc.NewRPCFunc(env.DumpConsensusState, "", false),
  34. "consensus_state": rpc.NewRPCFunc(env.GetConsensusState, "", false),
  35. "consensus_params": rpc.NewRPCFunc(env.ConsensusParams, "height", true),
  36. "unconfirmed_txs": rpc.NewRPCFunc(env.UnconfirmedTxs, "limit", false),
  37. "num_unconfirmed_txs": rpc.NewRPCFunc(env.NumUnconfirmedTxs, "", false),
  38. // tx broadcast API
  39. "broadcast_tx_commit": rpc.NewRPCFunc(env.BroadcastTxCommit, "tx", false),
  40. "broadcast_tx_sync": rpc.NewRPCFunc(env.BroadcastTxSync, "tx", false),
  41. "broadcast_tx_async": rpc.NewRPCFunc(env.BroadcastTxAsync, "tx", false),
  42. // abci API
  43. "abci_query": rpc.NewRPCFunc(env.ABCIQuery, "path,data,height,prove", false),
  44. "abci_info": rpc.NewRPCFunc(env.ABCIInfo, "", true),
  45. // evidence API
  46. "broadcast_evidence": rpc.NewRPCFunc(env.BroadcastEvidence, "evidence", false),
  47. }
  48. }
  49. // AddUnsafeRoutes adds unsafe routes.
  50. func (env *Environment) AddUnsafe(routes RoutesMap) {
  51. // control API
  52. routes["dial_seeds"] = rpc.NewRPCFunc(env.UnsafeDialSeeds, "seeds", false)
  53. routes["dial_peers"] = rpc.NewRPCFunc(env.UnsafeDialPeers, "peers,persistent,unconditional,private", false)
  54. routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(env.UnsafeFlushMempool, "", false)
  55. }