From 83e2408f819451eb59efdfe6cea15b0aa010d4f6 Mon Sep 17 00:00:00 2001 From: Fridrik Asmundsson Date: Tue, 28 Mar 2023 16:28:47 +0200 Subject: [PATCH] Only populate message index if config EnableMsgIndex is set --- cmd/lotus/daemon.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index 0fc96775d..704d9b470 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -48,6 +48,7 @@ import ( "github.com/filecoin-project/lotus/lib/ulimit" "github.com/filecoin-project/lotus/metrics" "github.com/filecoin-project/lotus/node" + "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/modules" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/testing" @@ -559,11 +560,23 @@ func ImportChain(ctx context.Context, r repo.Repo, fname string, snapshot bool) return err } - log.Info("populating message index...") - if err := index.PopulateAfterSnapshot(ctx, path.Join(lr.Path(), "sqlite"), cst); err != nil { + // populate the message index if user has EnableMsgIndex enabled + // + c, err := lr.Config() + if err != nil { return err } - log.Info("populating message index done") + cfg, ok := c.(*config.FullNode) + if !ok { + return xerrors.Errorf("invalid config for repo, got: %T", c) + } + if cfg.Index.EnableMsgIndex { + log.Info("populating message index...") + if err := index.PopulateAfterSnapshot(ctx, path.Join(lr.Path(), "sqlite"), cst); err != nil { + return err + } + log.Info("populating message index done") + } return nil }