deduplicate code
This commit is contained in:
parent
3d1b855f20
commit
3bd77701d8
@ -710,16 +710,7 @@ func (s *SplitStore) compactSimple(curTs *types.TipSet) error {
|
|||||||
return xerrors.Errorf("error syncing tracker: %w", err)
|
return xerrors.Errorf("error syncing tracker: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc, ok := s.hot.(interface{ CollectGarbage() error }); ok {
|
s.gcHotstore()
|
||||||
log.Infof("garbage collecting hotstore")
|
|
||||||
startGC := time.Now()
|
|
||||||
err = gc.CollectGarbage()
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("error garbage collecting hotstore: %s", err)
|
|
||||||
} else {
|
|
||||||
log.Infow("garbage collection done", "took", time.Since(startGC))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = s.setBaseEpoch(coldEpoch)
|
err = s.setBaseEpoch(coldEpoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -806,6 +797,19 @@ func (s *SplitStore) purgeTracking(cids []cid.Cid) error {
|
|||||||
return s.purgeBatch(cids, s.tracker.DeleteBatch)
|
return s.purgeBatch(cids, s.tracker.DeleteBatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SplitStore) gcHotstore() {
|
||||||
|
if gc, ok := s.hot.(interface{ CollectGarbage() error }); ok {
|
||||||
|
log.Infof("garbage collecting hotstore")
|
||||||
|
startGC := time.Now()
|
||||||
|
err := gc.CollectGarbage()
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("error garbage collecting hotstore: %s", err)
|
||||||
|
} else {
|
||||||
|
log.Infow("garbage collection done", "took", time.Since(startGC))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SplitStore) compactFull(curTs *types.TipSet) error {
|
func (s *SplitStore) compactFull(curTs *types.TipSet) error {
|
||||||
currentEpoch := curTs.Height()
|
currentEpoch := curTs.Height()
|
||||||
coldEpoch := s.baseEpoch + CompactionCold
|
coldEpoch := s.baseEpoch + CompactionCold
|
||||||
@ -1016,16 +1020,7 @@ func (s *SplitStore) compactFull(curTs *types.TipSet) error {
|
|||||||
return xerrors.Errorf("error syncing tracker: %w", err)
|
return xerrors.Errorf("error syncing tracker: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gc, ok := s.hot.(interface{ CollectGarbage() error }); ok {
|
s.gcHotstore()
|
||||||
log.Infof("garbage collecting hotstore")
|
|
||||||
startGC := time.Now()
|
|
||||||
err = gc.CollectGarbage()
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("error garbage collecting hotstore: %s", err)
|
|
||||||
} else {
|
|
||||||
log.Infow("garbage collection done", "took", time.Since(startGC))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = s.setBaseEpoch(coldEpoch)
|
err = s.setBaseEpoch(coldEpoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user