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.

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