wire in lifecycle context
This commit is contained in:
parent
5461548b7e
commit
b90cfff0aa
@ -94,7 +94,7 @@ type headChange struct {
|
|||||||
app []*types.TipSet
|
app []*types.TipSet
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMsgIndex(basePath string, cs ChainStore) (MsgIndex, error) {
|
func NewMsgIndex(lctx context.Context, basePath string, cs ChainStore) (MsgIndex, error) {
|
||||||
var (
|
var (
|
||||||
dbPath string
|
dbPath string
|
||||||
exists bool
|
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{
|
msgIndex := &msgIndex{
|
||||||
db: db,
|
db: db,
|
||||||
|
@ -30,7 +30,7 @@ func TestBasicMsgIndex(t *testing.T) {
|
|||||||
tmp := t.TempDir()
|
tmp := t.TempDir()
|
||||||
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
|
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
|
||||||
|
|
||||||
msgIndex, err := NewMsgIndex(tmp, cs)
|
msgIndex, err := NewMsgIndex(context.Background(), tmp, cs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
defer msgIndex.Close() //nolint
|
defer msgIndex.Close() //nolint
|
||||||
@ -58,7 +58,7 @@ func TestReorgMsgIndex(t *testing.T) {
|
|||||||
tmp := t.TempDir()
|
tmp := t.TempDir()
|
||||||
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
|
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
|
||||||
|
|
||||||
msgIndex, err := NewMsgIndex(tmp, cs)
|
msgIndex, err := NewMsgIndex(context.Background(), tmp, cs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
defer msgIndex.Close() //nolint
|
defer msgIndex.Close() //nolint
|
||||||
@ -102,7 +102,7 @@ func TestReconcileMsgIndex(t *testing.T) {
|
|||||||
tmp := t.TempDir()
|
tmp := t.TempDir()
|
||||||
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
|
t.Cleanup(func() { _ = os.RemoveAll(tmp) })
|
||||||
|
|
||||||
msgIndex, err := NewMsgIndex(tmp, cs)
|
msgIndex, err := NewMsgIndex(context.Background(), tmp, cs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
@ -129,7 +129,7 @@ func TestReconcileMsgIndex(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// reopen to reconcile
|
// reopen to reconcile
|
||||||
msgIndex, err = NewMsgIndex(tmp, cs)
|
msgIndex, err = NewMsgIndex(context.Background(), tmp, cs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
defer msgIndex.Close() //nolint
|
defer msgIndex.Close() //nolint
|
||||||
|
@ -7,16 +7,17 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/index"
|
"github.com/filecoin-project/lotus/chain/index"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"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()
|
basePath, err := r.SqlitePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msgIndex, err := index.NewMsgIndex(basePath, cs)
|
msgIndex, err := index.NewMsgIndex(helpers.LifecycleCtx(mctx, lc), basePath, cs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user