diff --git a/blockstore/splitstore/markset.go b/blockstore/splitstore/markset.go index 9aad9cdf036..34a12de38f5 100644 --- a/blockstore/splitstore/markset.go +++ b/blockstore/splitstore/markset.go @@ -34,6 +34,8 @@ type MarkSetEnv interface { // CreateVisitor is like Create, but returns a wider interface that supports atomic visits. // It may not be supported by some markset types (e.g. bloom). CreateVisitor(name string, sizeHint int64) (MarkSetVisitor, error) + // SupportsVisitor returns true if the marksets created by this environment support the visitor interface. + SupportsVisitor() bool Close() error } diff --git a/blockstore/splitstore/markset_badger.go b/blockstore/splitstore/markset_badger.go index 61956dbeaab..ae06a69f87e 100644 --- a/blockstore/splitstore/markset_badger.go +++ b/blockstore/splitstore/markset_badger.go @@ -76,6 +76,8 @@ func (e *BadgerMarkSetEnv) CreateVisitor(name string, sizeHint int64) (MarkSetVi return e.create(name, sizeHint) } +func (e *BadgerMarkSetEnv) SupportsVisitor() bool { return true } + func (e *BadgerMarkSetEnv) Close() error { return os.RemoveAll(e.path) } diff --git a/blockstore/splitstore/markset_bloom.go b/blockstore/splitstore/markset_bloom.go index 74526063314..26c6b06f63c 100644 --- a/blockstore/splitstore/markset_bloom.go +++ b/blockstore/splitstore/markset_bloom.go @@ -57,6 +57,8 @@ func (e *BloomMarkSetEnv) CreateVisitor(name string, sizeHint int64) (MarkSetVis return nil, xerrors.Errorf("bloom mark set does not support visitors due to false positives") } +func (e *BloomMarkSetEnv) SupportsVisitor() bool { return false } + func (e *BloomMarkSetEnv) Close() error { return nil } diff --git a/blockstore/splitstore/markset_map.go b/blockstore/splitstore/markset_map.go index 81c9f162034..07a7ae70d4c 100644 --- a/blockstore/splitstore/markset_map.go +++ b/blockstore/splitstore/markset_map.go @@ -38,6 +38,8 @@ func (e *MapMarkSetEnv) CreateVisitor(name string, sizeHint int64) (MarkSetVisit return e.create(name, sizeHint) } +func (e *MapMarkSetEnv) SupportsVisitor() bool { return true } + func (e *MapMarkSetEnv) Close() error { return nil } diff --git a/blockstore/splitstore/splitstore.go b/blockstore/splitstore/splitstore.go index f2fb6817c6b..0e34fe952cf 100644 --- a/blockstore/splitstore/splitstore.go +++ b/blockstore/splitstore/splitstore.go @@ -173,6 +173,10 @@ func Open(path string, ds dstore.Datastore, hot, cold bstore.Blockstore, cfg *Co return nil, err } + if !markSetEnv.SupportsVisitor() { + return nil, xerrors.Errorf("markset type does not support atomic visitors") + } + // and now we can make a SplitStore ss := &SplitStore{ cfg: cfg,