mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
Merge pull request #3670 from yutianwu/fix_proxy
[R4R] Fix missing context parameter in proxy
This commit is contained in:
commit
97ceeed054
@ -59,3 +59,5 @@
|
|||||||
* `Mempool#Update` and `BlockExecutor#Commit` now accept
|
* `Mempool#Update` and `BlockExecutor#Commit` now accept
|
||||||
`[]*abci.ResponseDeliverTx` - list of `DeliverTx` responses, which should
|
`[]*abci.ResponseDeliverTx` - list of `DeliverTx` responses, which should
|
||||||
match `block.Txs`
|
match `block.Txs`
|
||||||
|
- [lite] \#3669 Add context parameter to RPC Handlers in proxy routes (@yutianwu)
|
||||||
|
|
||||||
|
@ -5,12 +5,15 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
amino "github.com/tendermint/go-amino"
|
amino "github.com/tendermint/go-amino"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
|
||||||
|
|
||||||
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||||
"github.com/tendermint/tendermint/rpc/core"
|
"github.com/tendermint/tendermint/rpc/core"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
|
rpcserver "github.com/tendermint/tendermint/rpc/lib/server"
|
||||||
|
rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
|
||||||
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -66,21 +69,93 @@ func RPCRoutes(c rpcclient.Client) map[string]*rpcserver.RPCFunc {
|
|||||||
"unsubscribe_all": rpcserver.NewWSRPCFunc(c.(Wrapper).UnsubscribeAllWS, ""),
|
"unsubscribe_all": rpcserver.NewWSRPCFunc(c.(Wrapper).UnsubscribeAllWS, ""),
|
||||||
|
|
||||||
// info API
|
// info API
|
||||||
"status": rpcserver.NewRPCFunc(c.Status, ""),
|
"status": rpcserver.NewRPCFunc(makeStatusFunc(c), ""),
|
||||||
"blockchain": rpcserver.NewRPCFunc(c.BlockchainInfo, "minHeight,maxHeight"),
|
"blockchain": rpcserver.NewRPCFunc(makeBlockchainInfoFunc(c), "minHeight,maxHeight"),
|
||||||
"genesis": rpcserver.NewRPCFunc(c.Genesis, ""),
|
"genesis": rpcserver.NewRPCFunc(makeGenesisFunc(c), ""),
|
||||||
"block": rpcserver.NewRPCFunc(c.Block, "height"),
|
"block": rpcserver.NewRPCFunc(makeBlockFunc(c), "height"),
|
||||||
"commit": rpcserver.NewRPCFunc(c.Commit, "height"),
|
"commit": rpcserver.NewRPCFunc(makeCommitFunc(c), "height"),
|
||||||
"tx": rpcserver.NewRPCFunc(c.Tx, "hash,prove"),
|
"tx": rpcserver.NewRPCFunc(makeTxFunc(c), "hash,prove"),
|
||||||
"validators": rpcserver.NewRPCFunc(c.Validators, "height"),
|
"validators": rpcserver.NewRPCFunc(makeValidatorsFunc(c), "height"),
|
||||||
|
|
||||||
// broadcast API
|
// broadcast API
|
||||||
"broadcast_tx_commit": rpcserver.NewRPCFunc(c.BroadcastTxCommit, "tx"),
|
"broadcast_tx_commit": rpcserver.NewRPCFunc(makeBroadcastTxCommitFunc(c), "tx"),
|
||||||
"broadcast_tx_sync": rpcserver.NewRPCFunc(c.BroadcastTxSync, "tx"),
|
"broadcast_tx_sync": rpcserver.NewRPCFunc(makeBroadcastTxSyncFunc(c), "tx"),
|
||||||
"broadcast_tx_async": rpcserver.NewRPCFunc(c.BroadcastTxAsync, "tx"),
|
"broadcast_tx_async": rpcserver.NewRPCFunc(makeBroadcastTxAsyncFunc(c), "tx"),
|
||||||
|
|
||||||
// abci API
|
// abci API
|
||||||
"abci_query": rpcserver.NewRPCFunc(c.ABCIQuery, "path,data"),
|
"abci_query": rpcserver.NewRPCFunc(makeABCIQueryFunc(c), "path,data"),
|
||||||
"abci_info": rpcserver.NewRPCFunc(c.ABCIInfo, ""),
|
"abci_info": rpcserver.NewRPCFunc(makeABCIInfoFunc(c), ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeStatusFunc(c rpcclient.Client) func(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
|
||||||
|
return func(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
|
||||||
|
return c.Status()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeBlockchainInfoFunc(c rpcclient.Client) func(ctx *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) {
|
||||||
|
return func(ctx *rpctypes.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) {
|
||||||
|
return c.BlockchainInfo(minHeight, maxHeight)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeGenesisFunc(c rpcclient.Client) func(ctx *rpctypes.Context) (*ctypes.ResultGenesis, error) {
|
||||||
|
return func(ctx *rpctypes.Context) (*ctypes.ResultGenesis, error) {
|
||||||
|
return c.Genesis()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeBlockFunc(c rpcclient.Client) func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultBlock, error) {
|
||||||
|
return func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultBlock, error) {
|
||||||
|
return c.Block(height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCommitFunc(c rpcclient.Client) func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultCommit, error) {
|
||||||
|
return func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultCommit, error) {
|
||||||
|
return c.Commit(height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeTxFunc(c rpcclient.Client) func(ctx *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error) {
|
||||||
|
return func(ctx *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error) {
|
||||||
|
return c.Tx(hash, prove)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeValidatorsFunc(c rpcclient.Client) func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultValidators, error) {
|
||||||
|
return func(ctx *rpctypes.Context, height *int64) (*ctypes.ResultValidators, error) {
|
||||||
|
return c.Validators(height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeBroadcastTxCommitFunc(c rpcclient.Client) func(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||||
|
return func(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||||
|
return c.BroadcastTxCommit(tx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeBroadcastTxSyncFunc(c rpcclient.Client) func(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||||
|
return func(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||||
|
return c.BroadcastTxSync(tx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeBroadcastTxAsyncFunc(c rpcclient.Client) func(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||||
|
return func(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||||
|
return c.BroadcastTxAsync(tx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeABCIQueryFunc(c rpcclient.Client) func(ctx *rpctypes.Context, path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||||
|
return func(ctx *rpctypes.Context, path string, data cmn.HexBytes) (*ctypes.ResultABCIQuery, error) {
|
||||||
|
return c.ABCIQuery(path, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeABCIInfoFunc(c rpcclient.Client) func(ctx *rpctypes.Context) (*ctypes.ResultABCIInfo, error) {
|
||||||
|
return func(ctx *rpctypes.Context) (*ctypes.ResultABCIInfo, error) {
|
||||||
|
return c.ABCIInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user