abstract ChainStore interface

This commit is contained in:
vyzo 2023-03-11 17:55:48 +02:00 committed by Maciej Witowski
parent 3a06c7afaf
commit 46488d4356

View File

@ -18,8 +18,16 @@ import (
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
) )
// chain store interface; we could use store.ChainStore directly,
// but this simplifies unit testing.
type ChainStore interface {
SubscribeHeadChanges(f store.ReorgNotifee)
}
var _ ChainStore = (*store.ChainStore)(nil)
type msgIndex struct { type msgIndex struct {
cs *store.ChainStore cs ChainStore
db *sql.DB db *sql.DB
} }
@ -36,7 +44,7 @@ var (
coalesceMergeInterval = 100 * time.Millisecond coalesceMergeInterval = 100 * time.Millisecond
) )
func NewMsgIndex(basePath string, cs *store.ChainStore) (MsgIndex, error) { func NewMsgIndex(basePath string, cs ChainStore) (MsgIndex, error) {
var ( var (
mkdb bool mkdb bool
dbPath string dbPath string
@ -113,7 +121,7 @@ func createTables(db *sql.DB) error {
return errors.New("TODO: index.createTables") return errors.New("TODO: index.createTables")
} }
func reconcileIndex(db *sql.DB, cs *store.ChainStore) error { func reconcileIndex(db *sql.DB, cs ChainStore) error {
// TODO // TODO
return errors.New("TODO: index.reconcileIndex") return errors.New("TODO: index.reconcileIndex")
} }