storageminer: Restart sealing on restart

This commit is contained in:
Łukasz Magiera 2019-10-29 23:19:58 +01:00
parent 6c25c5384d
commit 922d8a90a5
2 changed files with 34 additions and 0 deletions

View File

@ -88,6 +88,10 @@ func (sb *SectorBuilder) SealSector(sectorID uint64, ticket SealTicket) (SealedS
return sectorbuilder.SealSector(sb.handle, sectorID, ticket)
}
func (sb *SectorBuilder) ResumeSealSector(sectorID uint64) (SealedSectorMetadata, error) {
return sectorbuilder.ResumeSealSector(sb.handle, sectorID)
}
func (sb *SectorBuilder) SealStatus(sector uint64) (SectorSealingStatus, error) {
return sectorbuilder.GetSectorSealingStatusByID(sb.handle, sector)
}

View File

@ -107,9 +107,39 @@ func (s *Store) poll() {
s.waitingLk.Unlock()
}
func (s *Store) restartSealing() {
sectors, err := s.sb.GetAllStagedSectors()
if err != nil {
return
}
for _, sid := range sectors {
status, err := s.sb.SealStatus(sid)
if err != nil {
return
}
if status.State != sealing_state.Paused {
continue
}
log.Infof("Sector %d is in paused state, resuming sealing", sid)
go func() {
// TODO: when we refactor wait-for-seal below, care about this output too
// (see SealSector below)
_, err := s.sb.ResumeSealSector(sid)
if err != nil {
return
}
}()
}
}
func (s *Store) service() {
poll := time.Tick(5 * time.Second)
s.restartSealing()
for {
select {
case <-poll: