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 }