mirror of
https://github.com/filecoin-project/lotus.git
synced 2025-05-17 15:20:37 +08:00
feat: implement ChainGetTipSet in Lotus v2 APIs (#13003)
Introduce the first API for Lotus v2, focusing on `ChainGetTipSet` within the `Chain` group. Define `TipSetSelector` for advanced tipset retrieval options, and create a compact JSON-RPC call format. Gracefully accommodate both EC and F3 finalized tipsets based on node configuration, where: * EC finalized tipset is returned when F3 is turned off, has no finalized tipset or F3 isn't ready. * F3 finalized is returned otherwise. Support three categories of selectors under `TipSetSelector`: * By tag: either "latest" or "finalized." * By height: epoch, plus optional fallback to previous non-null tipset. * By tipset key. The selection falls back to tag "latest" if the user specifies no selection criterion. The JSON-RPC format is designed to use JSON Object as the parameters passed to the RPC call to remain compact, and extensible.
This commit is contained in:
@ -31,6 +31,8 @@ import (
|
||||
"github.com/filecoin-project/go-paramfetch"
|
||||
|
||||
lapi "github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v1api"
|
||||
"github.com/filecoin-project/lotus/api/v2api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/build/buildconstants"
|
||||
"github.com/filecoin-project/lotus/chain/beacon/drand"
|
||||
@ -392,9 +394,11 @@ var DaemonCmd = &cli.Command{
|
||||
log.Warnf("unable to inject prometheus ipfs/go-metrics exporter; some metrics will be unavailable; err: %s", err)
|
||||
}
|
||||
|
||||
var api lapi.FullNode
|
||||
var v1 v1api.FullNode
|
||||
var v2 v2api.FullNode
|
||||
stop, err := node.New(ctx,
|
||||
node.FullAPI(&api, node.Lite(isLite)),
|
||||
node.FullAPI(&v1, node.Lite(isLite)),
|
||||
node.FullAPIv2(&v2),
|
||||
|
||||
node.Base(),
|
||||
node.Repo(r),
|
||||
@ -424,7 +428,7 @@ var DaemonCmd = &cli.Command{
|
||||
}
|
||||
|
||||
if cctx.String("import-key") != "" {
|
||||
if err := importKey(ctx, api, cctx.String("import-key")); err != nil {
|
||||
if err := importKey(ctx, v1, cctx.String("import-key")); err != nil {
|
||||
log.Errorf("importing key failed: %+v", err)
|
||||
}
|
||||
}
|
||||
@ -445,7 +449,7 @@ var DaemonCmd = &cli.Command{
|
||||
}
|
||||
|
||||
// Instantiate the full node handler.
|
||||
h, err := node.FullNodeHandler(api, true, serverOptions...)
|
||||
h, err := node.FullNodeHandler(v1, v2, true, serverOptions...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to instantiate rpc handler: %s", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user