Skip to content

Commit

Permalink
remove BlockstoreMover interface
Browse files Browse the repository at this point in the history
we decided it's premature
  • Loading branch information
vyzo committed Jul 14, 2021
1 parent 68da14c commit 7a89edc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
16 changes: 0 additions & 16 deletions blockstore/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ type BlockstoreIterator interface {
ForEachKey(func(cid.Cid) error) error
}

// BlockstoreMover is a trait for movable blockstores
type BlockstoreMover interface {
// Moves the blockstore to path, and creates a symlink from the current path
// to the new path; the old blockstore is deleted.
// If path is empty, then a new path adjacent to the current path is created
// automatically.
// If the filter function is not nil, then the move filters and moves only
// objects whose cid satisfyn the filter.
//
// The blockstore must accept new writes during the move and ensure that these
// are persisted to the new blockstore; if a failure occurs aboring the move,
// then they must be peristed to the old blockstore.
// In short, the blockstore must not lose data from new writes during the move.
MoveTo(path string, filter func(cid.Cid) bool) error
}

// BlockstoreGC is a trait for blockstores that support online garbage collection
type BlockstoreGC interface {
CollectGarbage() error
Expand Down
27 changes: 0 additions & 27 deletions blockstore/splitstore/splitstore_gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,14 @@ import (
"time"

bstore "github.com/filecoin-project/lotus/blockstore"
cid "github.com/ipfs/go-cid"
)

func (s *SplitStore) gcHotstore() {
// we only perform moving gc every 20 compactions (about once a week) as it can take a while
if s.compactionIndex%20 == 0 {
if err := s.gcBlockstoreMoving(s.hot, "", nil); err != nil {
log.Warnf("error moving hotstore: %s", err)
// fallthrough to online gc
} else {
return
}
}

if err := s.gcBlockstoreOnline(s.hot); err != nil {
log.Warnf("error garbage collecting hostore: %s", err)
}
}

func (s *SplitStore) gcBlockstoreMoving(b bstore.Blockstore, path string, filter func(cid.Cid) bool) error {
if mover, ok := b.(bstore.BlockstoreMover); ok {
log.Info("moving blockstore")
startMove := time.Now()

if err := mover.MoveTo(path, filter); err != nil {
return err
}

log.Infow("moving hotstore done", "took", time.Since(startMove))
return nil
}

return fmt.Errorf("blockstore doesn't support moving: %T", b)
}

func (s *SplitStore) gcBlockstoreOnline(b bstore.Blockstore) error {
if gc, ok := b.(bstore.BlockstoreGC); ok {
log.Info("garbage collecting blockstore")
Expand Down

0 comments on commit 7a89edc

Please sign in to comment.