move poller to sector store
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
package sectorbuilder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TODO: really need to get a callbacks API from the rust-sectorbuilder
|
||||
func (sb *SectorBuilder) pollForSealedSectors(ctx context.Context) {
|
||||
watching := make(map[uint64]bool)
|
||||
|
||||
staged, err := sb.GetAllStagedSectors()
|
||||
if err != nil {
|
||||
// TODO: this is probably worth shutting the miner down over until we
|
||||
// have better recovery mechanisms
|
||||
log.Errorf("failed to get staged sectors: %s", err)
|
||||
}
|
||||
for _, s := range staged {
|
||||
watching[s.SectorID] = true
|
||||
}
|
||||
|
||||
tick := time.Tick(time.Second * 5)
|
||||
for {
|
||||
select {
|
||||
case <-tick:
|
||||
log.Info("polling for sealed sectors...")
|
||||
|
||||
// add new staged sectors to watch list
|
||||
staged, err := sb.GetAllStagedSectors()
|
||||
if err != nil {
|
||||
log.Errorf("in loop: failed to get staged sectors: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
for _, s := range staged {
|
||||
watching[s.SectorID] = true
|
||||
}
|
||||
|
||||
for s := range watching {
|
||||
status, err := sb.SealStatus(s)
|
||||
if err != nil {
|
||||
log.Errorf("getting seal status: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if status.SealStatusCode == 0 { // constant pls, zero implies the last step?
|
||||
delete(watching, s)
|
||||
sb.sschan <- status
|
||||
}
|
||||
}
|
||||
case <-ctx.Done():
|
||||
close(sb.sschan)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package sectorbuilder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"unsafe"
|
||||
|
||||
@@ -22,8 +21,6 @@ const CommLen = sectorbuilder.CommitmentBytesLen
|
||||
|
||||
type SectorBuilder struct {
|
||||
handle unsafe.Pointer
|
||||
|
||||
sschan chan SectorSealingStatus
|
||||
}
|
||||
|
||||
type SectorBuilderConfig struct {
|
||||
@@ -44,7 +41,6 @@ func New(cfg *SectorBuilderConfig) (*SectorBuilder, error) {
|
||||
|
||||
return &SectorBuilder{
|
||||
handle: sbp,
|
||||
sschan: make(chan SectorSealingStatus, 32),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -60,10 +56,6 @@ func sectorIDtoBytes(sid uint64) [31]byte {
|
||||
return out
|
||||
}
|
||||
|
||||
func (sb *SectorBuilder) Run(ctx context.Context) {
|
||||
go sb.pollForSealedSectors(ctx)
|
||||
}
|
||||
|
||||
func (sb *SectorBuilder) Destroy() {
|
||||
sectorbuilder.DestroySectorBuilder(sb.handle)
|
||||
}
|
||||
@@ -95,11 +87,6 @@ func (sb *SectorBuilder) GeneratePoSt(sortedCommRs [][CommLen]byte, challengeSee
|
||||
return sectorbuilder.GeneratePoSt(sb.handle, sortedCommRs, challengeSeed)
|
||||
}
|
||||
|
||||
func (sb *SectorBuilder) SealedSectorChan() <-chan SectorSealingStatus {
|
||||
// is this ever going to be multi-consumer? If so, switch to using pubsub/eventbus
|
||||
return sb.sschan
|
||||
}
|
||||
|
||||
var UserBytesForSectorSize = sectorbuilder.GetMaxUserBytesPerStagedSector
|
||||
|
||||
func VerifySeal(sectorSize uint64, commR, commD, commRStar []byte, proverID address.Address, sectorID uint64, proof []byte) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user