From 174f8f3a7e7fe3ef02393d624ea8fea7286b0d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 17 Nov 2019 13:12:05 +0100 Subject: [PATCH 1/2] sectors: Simple state restore --- storage/sealing.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/storage/sealing.go b/storage/sealing.go index abb831676..3e3c576f5 100644 --- a/storage/sealing.go +++ b/storage/sealing.go @@ -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) { From ca70ac05d7456bdf119ab8a125556a906ee320b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 20 Nov 2019 20:59:10 +0100 Subject: [PATCH 2/2] sectorbuilder: Drop some unused functions --- lib/sectorbuilder/sectorbuilder.go | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index 7a71f4ab1..43ed38d22 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -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?