mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 11:45:18 +00:00
* rpc: Add caching support (#9650)
* Set cache control in the HTTP-RPC response header
* Add a simply cache policy to the RPC routes
* add a condition to check the RPC request has default height settings
* fix cherry pick error
* update pending log
* use options struct intead of single parameter
* refacor FuncOptions to functional options
* add functional options in WebSocket RPC function
* revert doc
* replace deprecated function call
* revise functional options
* remove unuse comment
* fix revised error
* adjust cache-control settings
* Update rpc/jsonrpc/server/http_json_handler.go
Co-authored-by: Thane Thomson <connect@thanethomson.com>
* linter: Fix false positive
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* rpc: Separate cacheable and non-cacheable HTTP response writers
Allows us to roll this change out in a non-API-breaking way, since this
is an additive change.
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* rpc: Ensure consistent caching strategy
Ensure a consistent caching strategy across both JSONRPC- and URI-based
requests.
This requires a bit of a refactor of the previous caching logic, which
is complicated a little by the complex reflection-based approach taken
in the Tendermint RPC.
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* rpc: Add more tests for caching
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* Update CHANGELOG_PENDING
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* light: Sync routes config with RPC core
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* rpc: Update OpenAPI docs
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: jayt106 <jaytseng106@gmail.com>
Co-authored-by: jay tseng <jay.tseng@crypto.com>
Co-authored-by: JayT106 <JayT106@users.noreply.github.com>
(cherry picked from commit 816c6bac00)
# Conflicts:
# CHANGELOG_PENDING.md
# light/proxy/routes.go
# rpc/core/routes.go
# rpc/openapi/openapi.yaml
# test/fuzz/tests/rpc_jsonrpc_server_test.go
* Fix conflict in CHANGELOG_PENDING
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* Resolve remaining conflicts
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: Thane Thomson <connect@thanethomson.com>
58 lines
2.7 KiB
Go
58 lines
2.7 KiB
Go
package core
|
|
|
|
import (
|
|
rpc "github.com/tendermint/tendermint/rpc/jsonrpc/server"
|
|
)
|
|
|
|
// TODO: better system than "unsafe" prefix
|
|
|
|
// Routes is a map of available routes.
|
|
var Routes = map[string]*rpc.RPCFunc{
|
|
// subscribe/unsubscribe are reserved for websocket events.
|
|
"subscribe": rpc.NewWSRPCFunc(Subscribe, "query"),
|
|
"unsubscribe": rpc.NewWSRPCFunc(Unsubscribe, "query"),
|
|
"unsubscribe_all": rpc.NewWSRPCFunc(UnsubscribeAll, ""),
|
|
|
|
// info API
|
|
"health": rpc.NewRPCFunc(Health, ""),
|
|
"status": rpc.NewRPCFunc(Status, ""),
|
|
"net_info": rpc.NewRPCFunc(NetInfo, ""),
|
|
"blockchain": rpc.NewRPCFunc(BlockchainInfo, "minHeight,maxHeight", rpc.Cacheable()),
|
|
"genesis": rpc.NewRPCFunc(Genesis, "", rpc.Cacheable()),
|
|
"genesis_chunked": rpc.NewRPCFunc(GenesisChunked, "chunk", rpc.Cacheable()),
|
|
"block": rpc.NewRPCFunc(Block, "height", rpc.Cacheable("height")),
|
|
"block_by_hash": rpc.NewRPCFunc(BlockByHash, "hash", rpc.Cacheable()),
|
|
"block_results": rpc.NewRPCFunc(BlockResults, "height", rpc.Cacheable("height")),
|
|
"commit": rpc.NewRPCFunc(Commit, "height", rpc.Cacheable("height")),
|
|
"check_tx": rpc.NewRPCFunc(CheckTx, "tx", rpc.Cacheable()),
|
|
"tx": rpc.NewRPCFunc(Tx, "hash,prove", rpc.Cacheable()),
|
|
"tx_search": rpc.NewRPCFunc(TxSearch, "query,prove,page,per_page,order_by"),
|
|
"block_search": rpc.NewRPCFunc(BlockSearch, "query,page,per_page,order_by"),
|
|
"validators": rpc.NewRPCFunc(Validators, "height,page,per_page", rpc.Cacheable("height")),
|
|
"dump_consensus_state": rpc.NewRPCFunc(DumpConsensusState, ""),
|
|
"consensus_state": rpc.NewRPCFunc(ConsensusState, ""),
|
|
"consensus_params": rpc.NewRPCFunc(ConsensusParams, "height", rpc.Cacheable("height")),
|
|
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxs, "limit"),
|
|
"num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxs, ""),
|
|
|
|
// tx broadcast API
|
|
"broadcast_tx_commit": rpc.NewRPCFunc(BroadcastTxCommit, "tx"),
|
|
"broadcast_tx_sync": rpc.NewRPCFunc(BroadcastTxSync, "tx"),
|
|
"broadcast_tx_async": rpc.NewRPCFunc(BroadcastTxAsync, "tx"),
|
|
|
|
// abci API
|
|
"abci_query": rpc.NewRPCFunc(ABCIQuery, "path,data,height,prove"),
|
|
"abci_info": rpc.NewRPCFunc(ABCIInfo, "", rpc.Cacheable()),
|
|
|
|
// evidence API
|
|
"broadcast_evidence": rpc.NewRPCFunc(BroadcastEvidence, "evidence"),
|
|
}
|
|
|
|
// AddUnsafeRoutes adds unsafe routes.
|
|
func AddUnsafeRoutes() {
|
|
// control API
|
|
Routes["dial_seeds"] = rpc.NewRPCFunc(UnsafeDialSeeds, "seeds")
|
|
Routes["dial_peers"] = rpc.NewRPCFunc(UnsafeDialPeers, "peers,persistent,unconditional,private")
|
|
Routes["unsafe_flush_mempool"] = rpc.NewRPCFunc(UnsafeFlushMempool, "")
|
|
}
|