2023-03-12 13:25:07 +00:00
|
|
|
package modules
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"go.uber.org/fx"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/chain/index"
|
|
|
|
"github.com/filecoin-project/lotus/chain/store"
|
2023-03-13 08:42:48 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
2023-03-12 13:25:07 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/repo"
|
|
|
|
)
|
|
|
|
|
2023-03-13 08:42:48 +00:00
|
|
|
func MsgIndex(lc fx.Lifecycle, mctx helpers.MetricsCtx, cs *store.ChainStore, r repo.LockedRepo) (index.MsgIndex, error) {
|
2023-03-12 13:25:07 +00:00
|
|
|
basePath, err := r.SqlitePath()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-03-13 08:42:48 +00:00
|
|
|
msgIndex, err := index.NewMsgIndex(helpers.LifecycleCtx(mctx, lc), basePath, cs)
|
2023-03-12 13:25:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
lc.Append(fx.Hook{
|
|
|
|
OnStop: func(_ context.Context) error {
|
|
|
|
return msgIndex.Close()
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
return msgIndex, nil
|
|
|
|
}
|
2023-03-12 14:02:51 +00:00
|
|
|
|
|
|
|
func DummyMsgIndex() (index.MsgIndex, error) {
|
|
|
|
return index.DummyMsgIndex, nil
|
|
|
|
}
|