Skip to content

Commit

Permalink
Add all RPC methods to Route map
Browse files Browse the repository at this point in the history
  • Loading branch information
vasylNaumenko committed Apr 30, 2024
1 parent fa97ac2 commit 46ef731
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions vm/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,27 @@ func NewRPC(vm *LandslideVM) *RPC {

func (rpc *RPC) Routes() map[string]*jsonrpc.RPCFunc {
return map[string]*jsonrpc.RPCFunc{
"status": jsonrpc.NewRPCFunc(rpc.Status, ""),
// info AP
"health": jsonrpc.NewRPCFunc(rpc.Health, ""),
"status": jsonrpc.NewRPCFunc(rpc.Status, ""),
"net_info": jsonrpc.NewRPCFunc(rpc.NetInfo, ""),
"blockchain": jsonrpc.NewRPCFunc(rpc.BlockchainInfo, "minHeight,maxHeight", jsonrpc.Cacheable()),
"genesis": jsonrpc.NewRPCFunc(rpc.Genesis, "", jsonrpc.Cacheable()),
"genesis_chunked": jsonrpc.NewRPCFunc(rpc.GenesisChunked, "chunk", jsonrpc.Cacheable()),
"block": jsonrpc.NewRPCFunc(rpc.Block, "height", jsonrpc.Cacheable("height")),
"block_by_hash": jsonrpc.NewRPCFunc(rpc.BlockByHash, "hash", jsonrpc.Cacheable()),
"block_results": jsonrpc.NewRPCFunc(rpc.BlockResults, "height", jsonrpc.Cacheable("height")),
"commit": jsonrpc.NewRPCFunc(rpc.Commit, "height", jsonrpc.Cacheable("height")),
"tx": jsonrpc.NewRPCFunc(rpc.Tx, "hash,prove", jsonrpc.Cacheable()),
"tx_search": jsonrpc.NewRPCFunc(rpc.TxSearch, "query,prove,page,per_page,order_by"),
"block_search": jsonrpc.NewRPCFunc(rpc.BlockSearch, "query,page,per_page,order_by"),
"validators": jsonrpc.NewRPCFunc(rpc.Validators, "height,page,per_page", jsonrpc.Cacheable("height")),
"dump_consensus_state": jsonrpc.NewRPCFunc(rpc.DumpConsensusState, ""),
"consensus_params": jsonrpc.NewRPCFunc(rpc.ConsensusParams, "height", jsonrpc.Cacheable("height")),

// tx broadcast API
"broadcast_tx_sync": jsonrpc.NewRPCFunc(rpc.BroadcastTxSync, "tx"),
"broadcast_tx_async": jsonrpc.NewRPCFunc(rpc.BroadcastTxAsync, "tx"),

// abci API
"abci_query": jsonrpc.NewRPCFunc(rpc.ABCIQuery, "path,data,height,prove"),
Expand Down Expand Up @@ -257,7 +277,6 @@ type BlockHeightArgs struct {
// bsHeight can be either latest committed or uncommitted (+1) height.
func getHeight(bs *store.BlockStore, heightPtr *int64) (int64, error) {
bsHeight := bs.Height()
bsBase := bs.Base()
if heightPtr != nil {
height := *heightPtr
if height <= 0 {
Expand All @@ -266,6 +285,7 @@ func getHeight(bs *store.BlockStore, heightPtr *int64) (int64, error) {
if height > bsHeight {
return 0, fmt.Errorf("height %d must be less than or equal to the current blockchain height %d", height, bsHeight)
}
bsBase := bs.Base()
if height < bsBase {
return 0, fmt.Errorf("height %d is not available, lowest height is %d", height, bsBase)
}
Expand Down Expand Up @@ -676,7 +696,7 @@ func (rpc *RPC) Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
EarliestBlockTime: time.Unix(0, earliestBlockTimeNano),
CatchingUp: false,
},
//TODO: use internal app validators instead
// TODO: use internal app validators instead
ValidatorInfo: ctypes.ValidatorInfo{
Address: proposerPubKey.Address(),
PubKey: proposerPubKey,
Expand Down

0 comments on commit 46ef731

Please sign in to comment.