Files
tendermint/light/proxy/routes.go
M. J. Fromberger 81ee41228a rpc: consolidate RPC route map construction (#7582)
Define interfaces for the various methods a service may implement.  This is
basically just the set of things on Environment that are exported as RPCs, but
these are also implemented by the light proxy.

* internal/rpc: use NewRoutesMap to construct routes on service start
* light/proxy: use NewRoutesMap to construct RPC routes
2022-01-13 10:45:36 -08:00

43 lines
1.3 KiB
Go

package proxy
import (
"context"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
lrpc "github.com/tendermint/tendermint/light/rpc"
rpcclient "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/coretypes"
)
// proxyService wraps a light RPC client to export the RPC service interfaces.
// This is needed because the service and the client use different signatures
// for some of the methods.
type proxyService struct {
*lrpc.Client
}
func (p proxyService) ABCIQuery(ctx context.Context, path string, data tmbytes.HexBytes,
height int64, prove bool) (*coretypes.ResultABCIQuery, error) {
return p.ABCIQueryWithOptions(ctx, path, data, rpcclient.ABCIQueryOptions{
Height: height,
Prove: prove,
})
}
func (p proxyService) GetConsensusState(ctx context.Context) (*coretypes.ResultConsensusState, error) {
return p.ConsensusState(ctx)
}
func (p proxyService) Subscribe(ctx context.Context, query string) (*coretypes.ResultSubscribe, error) {
return p.SubscribeWS(ctx, query)
}
func (p proxyService) Unsubscribe(ctx context.Context, query string) (*coretypes.ResultUnsubscribe, error) {
return p.UnsubscribeWS(ctx, query)
}
func (p proxyService) UnsubscribeAll(ctx context.Context) (*coretypes.ResultUnsubscribe, error) {
return p.UnsubscribeAllWS(ctx)
}