2020-11-26 14:53:16 +00:00
|
|
|
package splitstore
|
|
|
|
|
|
|
|
import (
|
2021-02-27 10:01:55 +00:00
|
|
|
"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"
|
2021-02-26 18:54:47 +00:00
|
|
|
cid "github.com/ipfs/go-cid"
|
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-02-27 21:08:23 +00:00
|
|
|
DeleteBatch(map[cid.Cid]struct{}) error
|
2021-02-26 13:59:36 +00:00
|
|
|
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
|
|
|
|
}
|
2021-02-27 10:01:55 +00:00
|
|
|
|
2021-02-28 07:59:11 +00:00
|
|
|
func NewTrackingStore(path string, trackingStoreType string) (TrackingStore, error) {
|
|
|
|
switch trackingStoreType {
|
|
|
|
case "", "bolt":
|
|
|
|
return NewBoltTrackingStore(filepath.Join(path, "snoop.bolt"))
|
|
|
|
case "lmdb":
|
2021-02-27 10:01:55 +00:00
|
|
|
return NewLMDBTrackingStore(filepath.Join(path, "snoop.lmdb"))
|
2021-02-28 07:59:11 +00:00
|
|
|
default:
|
|
|
|
return nil, xerrors.Errorf("unknown tracking store type %s", trackingStoreType)
|
2021-02-27 10:01:55 +00:00
|
|
|
}
|
|
|
|
}
|