35 lines
933 B
Go
35 lines
933 B
Go
package splitstore
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
cid "github.com/ipfs/go-cid"
|
|
)
|
|
|
|
// TrackingStore is a persistent store that tracks blocks that are added
|
|
// to the hotstore, tracking the epoch at which they are written.
|
|
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
|
|
DeleteBatch([]cid.Cid) error
|
|
ForEach(func(cid.Cid, abi.ChainEpoch) error) error
|
|
Sync() error
|
|
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 {
|
|
case "", "bolt":
|
|
return OpenBoltTrackingStore(filepath.Join(path, "tracker.bolt"))
|
|
default:
|
|
return nil, xerrors.Errorf("unknown tracking store type %s", ttype)
|
|
}
|
|
}
|