mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-16 12:16:11 +00:00
e2e: integrate light clients (#6196)
This commit is contained in:
@@ -8,7 +8,9 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
|
||||
"github.com/tendermint/tendermint/light"
|
||||
lrpc "github.com/tendermint/tendermint/light/rpc"
|
||||
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
|
||||
rpcserver "github.com/tendermint/tendermint/rpc/jsonrpc/server"
|
||||
)
|
||||
|
||||
@@ -21,6 +23,28 @@ type Proxy struct {
|
||||
Listener net.Listener
|
||||
}
|
||||
|
||||
// NewProxy creates the struct used to run an HTTP server for serving light
|
||||
// client rpc requests.
|
||||
func NewProxy(
|
||||
lightClient *light.Client,
|
||||
listenAddr, providerAddr string,
|
||||
config *rpcserver.Config,
|
||||
logger log.Logger,
|
||||
opts ...lrpc.Option,
|
||||
) (*Proxy, error) {
|
||||
rpcClient, err := rpchttp.NewWithTimeout(providerAddr, config.WriteTimeout)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create http client for %s: %w", providerAddr, err)
|
||||
}
|
||||
|
||||
return &Proxy{
|
||||
Addr: listenAddr,
|
||||
Config: config,
|
||||
Client: lrpc.NewClient(rpcClient, lightClient, opts...),
|
||||
Logger: logger,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListenAndServe configures the rpcserver.WebsocketManager, sets up the RPC
|
||||
// routes to proxy via Client, and starts up an HTTP server on the TCP network
|
||||
// address p.Addr.
|
||||
|
||||
Reference in New Issue
Block a user