2020-08-18 14:54:05 +00:00
|
|
|
package sealing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
|
|
)
|
|
|
|
|
|
|
|
type statSectorState int
|
2020-08-18 16:27:28 +00:00
|
|
|
|
2020-08-18 14:54:05 +00:00
|
|
|
const (
|
|
|
|
sstSealing statSectorState = iota
|
|
|
|
sstFailed
|
|
|
|
sstProving
|
|
|
|
nsst
|
|
|
|
)
|
|
|
|
|
|
|
|
type SectorStats struct {
|
|
|
|
lk sync.Mutex
|
|
|
|
|
|
|
|
bySector map[abi.SectorID]statSectorState
|
2020-08-18 16:27:28 +00:00
|
|
|
totals [nsst]uint64
|
2020-08-18 14:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ss *SectorStats) updateSector(id abi.SectorID, st SectorState) {
|
|
|
|
ss.lk.Lock()
|
|
|
|
defer ss.lk.Unlock()
|
|
|
|
|
|
|
|
oldst, found := ss.bySector[id]
|
|
|
|
if found {
|
|
|
|
ss.totals[oldst]--
|
|
|
|
}
|
|
|
|
|
|
|
|
sst := toStatState(st)
|
|
|
|
ss.bySector[id] = sst
|
|
|
|
ss.totals[sst]++
|
|
|
|
}
|
|
|
|
|
|
|
|
// return the number of sectors currently in the sealing pipeline
|
|
|
|
func (ss *SectorStats) curSealing() uint64 {
|
|
|
|
ss.lk.Lock()
|
|
|
|
defer ss.lk.Unlock()
|
|
|
|
|
|
|
|
return ss.totals[sstSealing] + ss.totals[sstFailed]
|
|
|
|
}
|