github.com/badrootd/celestia-core@v0.0.0-20240305091328-aa4207a4b25d/rpc/core/routes.go (about)

     1  package core
     2  
     3  import (
     4  	rpc "github.com/badrootd/celestia-core/rpc/jsonrpc/server"
     5  )
     6  
     7  // TODO: better system than "unsafe" prefix
     8  
     9  // Routes is a map of available routes.
    10  var Routes = map[string]*rpc.RPCFunc{
    11  	// subscribe/unsubscribe are reserved for websocket events.
    12  	"subscribe":       rpc.NewWSRPCFunc(Subscribe, "query"),
    13  	"unsubscribe":     rpc.NewWSRPCFunc(Unsubscribe, "query"),
    14  	"unsubscribe_all": rpc.NewWSRPCFunc(UnsubscribeAll, ""),
    15  
    16  	// info API
    17  	"health":                    rpc.NewRPCFunc(Health, ""),
    18  	"status":                    rpc.NewRPCFunc(Status, ""),
    19  	"net_info":                  rpc.NewRPCFunc(NetInfo, ""),
    20  	"blockchain":                rpc.NewRPCFunc(BlockchainInfo, "minHeight,maxHeight", rpc.Cacheable()),
    21  	"genesis":                   rpc.NewRPCFunc(Genesis, "", rpc.Cacheable()),
    22  	"genesis_chunked":           rpc.NewRPCFunc(GenesisChunked, "chunk", rpc.Cacheable()),
    23  	"block":                     rpc.NewRPCFunc(Block, "height", rpc.Cacheable("height")),
    24  	"signed_block":              rpc.NewRPCFunc(SignedBlock, "height", rpc.Cacheable("height")),
    25  	"block_by_hash":             rpc.NewRPCFunc(BlockByHash, "hash", rpc.Cacheable()),
    26  	"block_results":             rpc.NewRPCFunc(BlockResults, "height", rpc.Cacheable("height")),
    27  	"commit":                    rpc.NewRPCFunc(Commit, "height", rpc.Cacheable("height")),
    28  	"header":                    rpc.NewRPCFunc(Header, "height", rpc.Cacheable("height")),
    29  	"header_by_hash":            rpc.NewRPCFunc(HeaderByHash, "hash"),
    30  	"data_commitment":           rpc.NewRPCFunc(DataCommitment, "start,end"),
    31  	"check_tx":                  rpc.NewRPCFunc(CheckTx, "tx"),
    32  	"tx":                        rpc.NewRPCFunc(Tx, "hash,prove", rpc.Cacheable()),
    33  	"prove_shares":              rpc.NewRPCFunc(ProveShares, "height,startShare,endShare"),
    34  	"data_root_inclusion_proof": rpc.NewRPCFunc(DataRootInclusionProof, "height,start,end"),
    35  	"tx_search":                 rpc.NewRPCFunc(TxSearchMatchEvents, "query,prove,page,per_page,order_by,match_events"),
    36  	"block_search":              rpc.NewRPCFunc(BlockSearchMatchEvents, "query,page,per_page,order_by,match_events"),
    37  	"validators":                rpc.NewRPCFunc(Validators, "height,page,per_page", rpc.Cacheable("height")),
    38  	"dump_consensus_state":      rpc.NewRPCFunc(DumpConsensusState, ""),
    39  	"consensus_state":           rpc.NewRPCFunc(ConsensusState, ""),
    40  	"consensus_params":          rpc.NewRPCFunc(ConsensusParams, "height", rpc.Cacheable("height")),
    41  	"unconfirmed_txs":           rpc.NewRPCFunc(UnconfirmedTxs, "limit"),
    42  	"num_unconfirmed_txs":       rpc.NewRPCFunc(NumUnconfirmedTxs, ""),
    43  
    44  	// tx broadcast API
    45  	"broadcast_tx_commit": rpc.NewRPCFunc(BroadcastTxCommit, "tx"),
    46  	"broadcast_tx_sync":   rpc.NewRPCFunc(BroadcastTxSync, "tx"),
    47  	"broadcast_tx_async":  rpc.NewRPCFunc(BroadcastTxAsync, "tx"),
    48  
    49  	// abci API
    50  	"abci_query": rpc.NewRPCFunc(ABCIQuery, "path,data,height,prove"),
    51  	"abci_info":  rpc.NewRPCFunc(ABCIInfo, "", rpc.Cacheable()),
    52  
    53  	// evidence API
    54  	"broadcast_evidence": rpc.NewRPCFunc(BroadcastEvidence, "evidence"),
    55  }
    56  
    57  // AddUnsafeRoutes adds unsafe routes.
    58  func AddUnsafeRoutes() {
    59  	// control API
    60  	Routes["dial_seeds"] = rpc.NewRPCFunc(UnsafeDialSeeds, "seeds")
    61  	Routes["dial_peers"] = rpc.NewRPCFunc(UnsafeDialPeers, "peers,persistent,unconditional,private")
    62  	Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "")
    63  }