renames and polish.

This commit is contained in:
Raúl Kripalani 2021-03-01 17:39:00 +00:00 committed by vyzo
parent b1b452bc0f
commit 8cfba5b092
8 changed files with 34 additions and 35 deletions

View File

@ -14,14 +14,14 @@ type LiveSet interface {
Close() error
}
var markBytes = []byte{}
var markBytes []byte
type LiveSetEnv interface {
NewLiveSet(name string, sizeHint int64) (LiveSet, error)
Close() error
}
func NewLiveSetEnv(path string, liveSetType string) (LiveSetEnv, error) {
func OpenLiveSetEnv(path string, liveSetType string) (LiveSetEnv, error) {
switch liveSetType {
case "", "bloom":
return NewBloomLiveSetEnv()

View File

@ -42,7 +42,7 @@ func (e *BloomLiveSetEnv) NewLiveSet(name string, sizeHint int64) (LiveSet, erro
return nil, xerrors.Errorf("error reading salt: %w", err)
}
bf, err := bbloom.New(float64(size), float64(BloomFilterProbability))
bf, err := bbloom.New(float64(size), BloomFilterProbability)
if err != nil {
return nil, xerrors.Errorf("error creating bloom filter: %w", err)
}

View File

@ -26,7 +26,7 @@ func testLiveSet(t *testing.T, lsType string) {
t.Fatal(err)
}
env, err := NewLiveSetEnv(path, lsType)
env, err := OpenLiveSetEnv(path, lsType)
if err != nil {
t.Fatal(err)
}

View File

@ -31,13 +31,12 @@ var (
var (
baseEpochKey = dstore.NewKey("/splitstore/baseEpoch")
warmupEpochKey = dstore.NewKey("/splitstore/warmupEpoch")
log = logging.Logger("splitstore")
)
var log = logging.Logger("splitstore")
func init() {
// TODO temporary for debugging purposes; to be removed for merge.
logging.SetLogLevel("splitstore", "DEBUG")
_ = logging.SetLogLevel("splitstore", "DEBUG")
}
type Config struct {
@ -94,20 +93,20 @@ type SplitStore struct {
var _ bstore.Blockstore = (*SplitStore)(nil)
// NewSplitStore creates a new SplitStore instance, given a path for the hotstore dbs and a cold
// blockstore. The SplitStore must be attached to the ChainStore with Start in order to trigger
// compaction.
func NewSplitStore(path string, ds dstore.Datastore, cold, hot bstore.Blockstore, cfg *Config) (*SplitStore, error) {
// Open opens an existing splistore, or creates a new splitstore. The splitstore
// is backed by the provided hot and cold stores. The returned SplitStore MUST be
// attached to the ChainStore with Start in order to trigger compaction.
func Open(path string, ds dstore.Datastore, hot, cold bstore.Blockstore, cfg *Config) (*SplitStore, error) {
// the tracking store
snoop, err := NewTrackingStore(path, cfg.TrackingStoreType)
snoop, err := OpenTrackingStore(path, cfg.TrackingStoreType)
if err != nil {
return nil, err
}
// the liveset env
env, err := NewLiveSetEnv(path, cfg.LiveSetType)
env, err := OpenLiveSetEnv(path, cfg.LiveSetType)
if err != nil {
snoop.Close() //nolint:errcheck
_ = snoop.Close()
return nil, err
}
@ -129,7 +128,7 @@ func NewSplitStore(path string, ds dstore.Datastore, cold, hot bstore.Blockstore
}
// Blockstore interface
func (s *SplitStore) DeleteBlock(cid cid.Cid) error {
func (s *SplitStore) DeleteBlock(_ cid.Cid) error {
// afaict we don't seem to be using this method, so it's not implemented
return errors.New("DeleteBlock not implemented on SplitStore; don't do this Luke!") //nolint
}
@ -377,7 +376,7 @@ func (s *SplitStore) warmup(curTs *types.TipSet) {
epoch := curTs.Height()
count := int64(0)
err := s.cs.WalkSnapshot(context.Background(), curTs, 1, s.skipOldMsgs, s.skipMsgReceipts,
err := s.chain.WalkSnapshot(context.Background(), curTs, 1, s.skipOldMsgs, s.skipMsgReceipts,
func(cid cid.Cid) error {
count++

View File

@ -20,10 +20,10 @@ type TrackingStore interface {
Close() error
}
func NewTrackingStore(path string, trackingStoreType string) (TrackingStore, error) {
func OpenTrackingStore(path string, trackingStoreType string) (TrackingStore, error) {
switch trackingStoreType {
case "", "bolt":
return NewBoltTrackingStore(filepath.Join(path, "snoop.bolt"))
return OpenBoltTrackingStore(filepath.Join(path, "snoop.bolt"))
default:
return nil, xerrors.Errorf("unknown tracking store type %s", trackingStoreType)
}

View File

@ -18,12 +18,12 @@ type BoltTrackingStore struct {
var _ TrackingStore = (*BoltTrackingStore)(nil)
func NewBoltTrackingStore(path string) (*BoltTrackingStore, error) {
db, err := bolt.Open(path, 0644,
&bolt.Options{
Timeout: 1 * time.Second,
NoSync: true,
})
func OpenBoltTrackingStore(path string) (*BoltTrackingStore, error) {
opts := &bolt.Options{
Timeout: 1 * time.Second,
NoSync: true,
}
db, err := bolt.Open(path, 0644, opts)
if err != nil {
return nil, err
}
@ -38,7 +38,7 @@ func NewBoltTrackingStore(path string) (*BoltTrackingStore, error) {
})
if err != nil {
db.Close() //nolint:errcheck
_ = db.Close()
return nil, err
}

View File

@ -51,7 +51,7 @@ func testTrackingStore(t *testing.T, tsType string) {
t.Fatal(err)
}
s, err := NewTrackingStore(path, tsType)
s, err := OpenTrackingStore(path, tsType)
if err != nil {
t.Fatal(err)
}
@ -118,7 +118,7 @@ func testTrackingStore(t *testing.T, tsType string) {
t.Fatal(err)
}
s, err = NewTrackingStore(path, tsType)
s, err = OpenTrackingStore(path, tsType)
if err != nil {
t.Fatal(err)
}

View File

@ -74,14 +74,14 @@ func SplitBlockstore(cfg *config.Blockstore) func(lc fx.Lifecycle, r repo.Locked
return nil, err
}
ss, err := splitstore.NewSplitStore(path, ds, cold, hot,
&splitstore.Config{
TrackingStoreType: cfg.Splitstore.TrackingStoreType,
LiveSetType: cfg.Splitstore.LiveSetType,
EnableFullCompaction: cfg.Splitstore.EnableFullCompaction,
EnableGC: cfg.Splitstore.EnableGC,
Archival: cfg.Splitstore.Archival,
})
cfg := &splitstore.Config{
TrackingStoreType: cfg.Splitstore.TrackingStoreType,
LiveSetType: cfg.Splitstore.LiveSetType,
EnableFullCompaction: cfg.Splitstore.EnableFullCompaction,
EnableGC: cfg.Splitstore.EnableGC,
Archival: cfg.Splitstore.Archival,
}
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
if err != nil {
return nil, err
}