From 37d94a3c9183c31f069f0861357bac186708af30 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 11 May 2022 22:45:06 +0300 Subject: [PATCH] move cli bundle loading back to init --- cli/init.go | 19 +++++++++++++++++++ cli/util/api.go | 16 ---------------- 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 cli/init.go diff --git a/cli/init.go b/cli/init.go new file mode 100644 index 000000000..199fb86e2 --- /dev/null +++ b/cli/init.go @@ -0,0 +1,19 @@ +package cli + +import ( + "context" + + "github.com/filecoin-project/lotus/blockstore" + "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors" +) + +func init() { + // preload manifest so that we have the correct code CID inventory for cli since that doesn't + // go through CI + bs := blockstore.NewMemory() + + if err := actors.FetchAndLoadBundles(context.Background(), bs, build.BuiltinActorReleases); err != nil { + panic(err) + } +} diff --git a/cli/util/api.go b/cli/util/api.go index 65afaf955..6c673d91f 100644 --- a/cli/util/api.go +++ b/cli/util/api.go @@ -21,9 +21,6 @@ import ( "github.com/filecoin-project/lotus/api/client" "github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/api/v1api" - "github.com/filecoin-project/lotus/blockstore" - "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/node/repo" ) @@ -31,14 +28,6 @@ const ( metadataTraceContext = "traceContext" ) -func loadBundles(ctx context.Context) error { - // preload manifest so that we have the correct code CID inventory for cli since that doesn't - // go through CI - bs := blockstore.NewMemory() - - return actors.FetchAndLoadBundles(ctx, bs, build.BuiltinActorReleases) -} - // GetAPIInfo returns the API endpoint to use for the specified kind of repo. // // The order of precedence is as follows: @@ -48,11 +37,6 @@ func loadBundles(ctx context.Context) error { // 3. deprecated *_API_INFO environment variables // 4. *-repo command line flags. func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) { - // do this first - if err := loadBundles(ctx.Context); err != nil { - return APIInfo{}, fmt.Errorf("error loading builtin-actor bundles: %w", err) - } - // Check if there was a flag passed with the listen address of the API // server (only used by the tests) for _, f := range t.APIFlags() {