add flags to control gateway lookback parameters

This commit is contained in:
whyrusleeping 2021-05-13 11:00:42 -07:00
parent 7ce1312fc2
commit b4b38788ef

View File

@ -8,6 +8,7 @@ import (
"contrib.go.opencensus.io/exporter/prometheus" "contrib.go.opencensus.io/exporter/prometheus"
"github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/go-state-types/abi"
promclient "github.com/prometheus/client_golang/prometheus" promclient "github.com/prometheus/client_golang/prometheus"
"go.opencensus.io/tag" "go.opencensus.io/tag"
@ -70,6 +71,16 @@ var runCmd = &cli.Command{
Name: "api-max-req-size", Name: "api-max-req-size",
Usage: "maximum API request size accepted by the JSON RPC server", Usage: "maximum API request size accepted by the JSON RPC server",
}, },
&cli.DurationFlag{
Name: "api-max-lookback",
Usage: "maximum duration allowable for tipset lookbacks",
Value: LookbackCap,
},
&cli.Int64Flag{
Name: "api-wait-lookback-limit",
Usage: "maximum number of blocks to search back through for message inclusion",
Value: int64(StateWaitLookbackLimit),
},
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
log.Info("Starting lotus gateway") log.Info("Starting lotus gateway")
@ -107,7 +118,11 @@ var runCmd = &cli.Command{
mux.Handle(path, rpcServer) mux.Handle(path, rpcServer)
} }
ma := metrics.MetricedGatewayAPI(NewGatewayAPI(api)) lookbackCap := cctx.Duration("api-max-lookback")
waitLookback := abi.ChainEpoch(cctx.Int64("api-wait-lookback-limit"))
ma := metrics.MetricedGatewayAPI(newGatewayAPI(api, lookbackCap, waitLookback))
serveRpc("/rpc/v1", ma) serveRpc("/rpc/v1", ma)
serveRpc("/rpc/v0", lapi.Wrap(new(v1api.FullNodeStruct), new(v0api.WrapperV1Full), ma)) serveRpc("/rpc/v0", lapi.Wrap(new(v1api.FullNodeStruct), new(v0api.WrapperV1Full), ma))