Merge pull request #650 from filecoin-project/feat/sector-improvements

sectors: Simple state restore
This commit is contained in:
Łukasz Magiera 2019-11-20 14:33:36 -06:00 committed by GitHub
commit 6b36f19a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 25 deletions

View File

@ -5,7 +5,6 @@ import (
"fmt"
"io"
"os"
"sort"
"strconv"
"sync"
"unsafe"
@ -311,28 +310,6 @@ func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed Sea
return proof, nil
}
func (sb *SectorBuilder) SealStatus(sector uint64) (SectorSealingStatus, error) {
return sectorbuilder.GetSectorSealingStatusByID(sb.handle, sector)
}
func (sb *SectorBuilder) GetAllStagedSectors() ([]uint64, error) {
sectors, err := sectorbuilder.GetAllStagedSectors(sb.handle)
if err != nil {
return nil, err
}
out := make([]uint64, len(sectors))
for i, v := range sectors {
out[i] = v.SectorID
}
sort.Slice(out, func(i, j int) bool {
return out[i] < out[j]
})
return out, nil
}
func (sb *SectorBuilder) GeneratePoSt(sectorInfo SortedSectorInfo, challengeSeed [CommLen]byte, faults []uint64) ([]byte, error) {
// Wait, this is a blocking method with no way of interrupting it?
// does it checkpoint itself?

View File

@ -124,8 +124,27 @@ func (t *SectorInfo) rspco() sectorbuilder.RawSealPreCommitOutput {
return out
}
func (m *Miner) sectorStateLoop(ctx context.Context) {
// TODO: restore state
func (m *Miner) sectorStateLoop(ctx context.Context) error {
toRestart, err := m.ListSectors()
if err != nil {
return err
}
go func() {
for _, si := range toRestart {
select {
case m.sectorUpdated <- sectorUpdate{
newState: si.State,
id: si.SectorID,
err: nil,
mut: nil,
}:
case <-ctx.Done():
log.Warn("didn't restart processing for all sectors: ", ctx.Err())
return
}
}
}()
go func() {
defer log.Warn("quitting deal provider loop")
@ -142,6 +161,8 @@ func (m *Miner) sectorStateLoop(ctx context.Context) {
}
}
}()
return nil
}
func (m *Miner) onSectorIncoming(sector *SectorInfo) {