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
|
|
|
cid "github.com/ipfs/go-cid"
|
|
|
|
)
|
|
|
|
|
|
|
|
type LiveSet interface {
|
|
|
|
Mark(cid.Cid) error
|
|
|
|
Has(cid.Cid) (bool, error)
|
|
|
|
Close() error
|
|
|
|
}
|
2020-11-26 15:49:47 +00:00
|
|
|
|
2020-11-26 16:58:03 +00:00
|
|
|
var markBytes = []byte{}
|
2021-02-27 10:01:55 +00:00
|
|
|
|
|
|
|
type LiveSetEnv interface {
|
2021-02-28 19:35:18 +00:00
|
|
|
NewLiveSet(name string, sizeHint int64) (LiveSet, error)
|
2021-02-27 10:01:55 +00:00
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
|
2021-02-28 07:59:11 +00:00
|
|
|
func NewLiveSetEnv(path string, liveSetType string) (LiveSetEnv, error) {
|
|
|
|
switch liveSetType {
|
|
|
|
case "", "bloom":
|
|
|
|
return NewBloomLiveSetEnv()
|
|
|
|
case "bolt":
|
|
|
|
return NewBoltLiveSetEnv(filepath.Join(path, "sweep.bolt"))
|
|
|
|
case "lmdb":
|
2021-02-27 10:01:55 +00:00
|
|
|
return NewLMDBLiveSetEnv(filepath.Join(path, "sweep.lmdb"))
|
2021-02-28 07:59:11 +00:00
|
|
|
default:
|
|
|
|
return nil, xerrors.Errorf("unknown live set type %s", liveSetType)
|
2021-02-27 10:01:55 +00:00
|
|
|
}
|
|
|
|
}
|