wire in lifecycle context

This commit is contained in:
vyzo 2023-03-13 10:42:48 +02:00
parent 5461548b7e
commit b90cfff0aa
3 changed files with 9 additions and 8 deletions

View File

@ -94,7 +94,7 @@ type headChange struct {
app []*types.TipSet
}
func NewMsgIndex(basePath string, cs ChainStore) (MsgIndex, error) {
func NewMsgIndex(lctx context.Context, basePath string, cs ChainStore) (MsgIndex, error) {
var (
dbPath string
exists bool
@ -136,7 +136,7 @@ func NewMsgIndex(basePath string, cs ChainStore) (MsgIndex, error) {
}
}
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(lctx)
msgIndex := &msgIndex{
db: db,

View File

@ -30,7 +30,7 @@ func TestBasicMsgIndex(t *testing.T) {
tmp := t.TempDir()
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
msgIndex, err := NewMsgIndex(tmp, cs)
msgIndex, err := NewMsgIndex(context.Background(), tmp, cs)
require.NoError(t, err)
defer msgIndex.Close() //nolint
@ -58,7 +58,7 @@ func TestReorgMsgIndex(t *testing.T) {
tmp := t.TempDir()
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
msgIndex, err := NewMsgIndex(tmp, cs)
msgIndex, err := NewMsgIndex(context.Background(), tmp, cs)
require.NoError(t, err)
defer msgIndex.Close() //nolint
@ -102,7 +102,7 @@ func TestReconcileMsgIndex(t *testing.T) {
tmp := t.TempDir()
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
msgIndex, err := NewMsgIndex(tmp, cs)
msgIndex, err := NewMsgIndex(context.Background(), tmp, cs)
require.NoError(t, err)
for i := 0; i < 10; i++ {
@ -129,7 +129,7 @@ func TestReconcileMsgIndex(t *testing.T) {
require.NoError(t, err)
// reopen to reconcile
msgIndex, err = NewMsgIndex(tmp, cs)
msgIndex, err = NewMsgIndex(context.Background(), tmp, cs)
require.NoError(t, err)
defer msgIndex.Close() //nolint

View File

@ -7,16 +7,17 @@ import (
"github.com/filecoin-project/lotus/chain/index"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/node/modules/helpers"
"github.com/filecoin-project/lotus/node/repo"
)
func MsgIndex(lc fx.Lifecycle, cs *store.ChainStore, r repo.LockedRepo) (index.MsgIndex, error) {
func MsgIndex(lc fx.Lifecycle, mctx helpers.MetricsCtx, cs *store.ChainStore, r repo.LockedRepo) (index.MsgIndex, error) {
basePath, err := r.SqlitePath()
if err != nil {
return nil, err
}
msgIndex, err := index.NewMsgIndex(basePath, cs)
msgIndex, err := index.NewMsgIndex(helpers.LifecycleCtx(mctx, lc), basePath, cs)
if err != nil {
return nil, err
}