fix: add lk.Lock() and move the map copy to avoid miner crash
This commit is contained in:
@@ -304,8 +304,18 @@ func (m *Sealing) TerminateSector(ctx context.Context, sid abi.SectorNumber) err
|
||||
return m.sectors.Send(uint64(sid), SectorTerminate{})
|
||||
}
|
||||
|
||||
func (m *Sealing) SectorsSummary(ctx context.Context) map[SectorState]int64 {
|
||||
return m.stats.byState
|
||||
func (m *Sealing) SectorsSummary(ctx context.Context) map[api.SectorState]int {
|
||||
m.stats.lk.Lock()
|
||||
defer m.stats.lk.Unlock()
|
||||
|
||||
out := make(map[api.SectorState]int)
|
||||
|
||||
for st, count := range m.stats.byState {
|
||||
state := api.SectorState(st)
|
||||
out[state] = int(count)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func (m *Sealing) TerminateFlush(ctx context.Context) (*cid.Cid, error) {
|
||||
|
||||
Reference in New Issue
Block a user