lotus/blockstore/splitstore/splitstore_gc.go

31 lines
664 B
Go
Raw Normal View History

2021-07-11 05:38:57 +00:00
package splitstore
import (
"fmt"
2021-07-11 05:38:57 +00:00
"time"
bstore "github.com/filecoin-project/lotus/blockstore"
)
func (s *SplitStore) gcHotstore() {
if err := s.gcBlockstoreOnline(s.hot); err != nil {
log.Warnf("error garbage collecting hostore: %s", err)
}
}
func (s *SplitStore) gcBlockstoreOnline(b bstore.Blockstore) error {
if gc, ok := b.(bstore.BlockstoreGC); ok {
log.Info("garbage collecting blockstore")
2021-07-11 05:38:57 +00:00
startGC := time.Now()
if err := gc.CollectGarbage(); err != nil {
return err
2021-07-11 05:38:57 +00:00
}
log.Infow("garbage collecting hotstore done", "took", time.Since(startGC))
return nil
2021-07-11 05:38:57 +00:00
}
return fmt.Errorf("blockstore doesn't support online gc: %T", b)
2021-07-11 05:38:57 +00:00
}