lotus/blockstore/splitstore/tracking.go

35 lines
933 B
Go
Raw Normal View History

2020-11-26 14:53:16 +00:00
package splitstore
import (
"path/filepath"
2021-02-28 07:59:11 +00:00
"golang.org/x/xerrors"
2020-11-26 14:53:16 +00:00
"github.com/filecoin-project/go-state-types/abi"
cid "github.com/ipfs/go-cid"
2020-11-26 14:53:16 +00:00
)
// TrackingStore is a persistent store that tracks blocks that are added
2021-03-02 08:04:02 +00:00
// to the hotstore, tracking the epoch at which they are written.
2020-11-26 14:53:16 +00:00
type TrackingStore interface {
Put(cid.Cid, abi.ChainEpoch) error
PutBatch([]cid.Cid, abi.ChainEpoch) error
Get(cid.Cid) (abi.ChainEpoch, error)
Delete(cid.Cid) error
2021-03-02 16:59:00 +00:00
DeleteBatch([]cid.Cid) error
ForEach(func(cid.Cid, abi.ChainEpoch) error) error
2021-02-27 16:16:09 +00:00
Sync() error
2020-11-26 18:37:02 +00:00
Close() error
}
// OpenTrackingStore opens a tracking store of the specified type in the
// specified path.
func OpenTrackingStore(path string, ttype string) (TrackingStore, error) {
switch ttype {
2021-02-28 07:59:11 +00:00
case "", "bolt":
return OpenBoltTrackingStore(filepath.Join(path, "tracker.bolt"))
2021-02-28 07:59:11 +00:00
default:
return nil, xerrors.Errorf("unknown tracking store type %s", ttype)
}
}