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