feat: load SectorsSummmary from SectorStats instead of calling API (faster)

This commit is contained in:
Florian RUEN 2023-10-25 18:32:02 +02:00
parent 12b30c0069
commit 02929dd166
No known key found for this signature in database
GPG Key ID: 6231FA69595430C7
3 changed files with 11 additions and 8 deletions

View File

@ -3,6 +3,7 @@
# UNRELEASED
- chore: Auto remove local chain data when importing chain file or snapshot ([filecoin-project/lotus#11277](https://github.com/filecoin-project/lotus/pull/11277))
- feat: metric: export Mpool message count ([filecoin-project/lotus#11361](https://github.com/filecoin-project/lotus/pull/11361))
- feat: sealing: load SectorsSummary from sealing SectorStats instead of calling API each time ([filecoin-project/lotus#11353](https://github.com/filecoin-project/lotus/pull/11353))
## New features
- feat: Added new tracing API (**HIGHLY EXPERIMENTAL**) supporting two RPC methods: `trace_block` and `trace_replayBlockTransactions` ([filecoin-project/lotus#11100](https://github.com/filecoin-project/lotus/pull/11100))

View File

@ -336,16 +336,14 @@ func (sm *StorageMinerAPI) SectorsListInStates(ctx context.Context, states []api
return sns, nil
}
// Use SectorsSummary from stats (prometheus) for faster result
func (sm *StorageMinerAPI) SectorsSummary(ctx context.Context) (map[api.SectorState]int, error) {
sectors, err := sm.Miner.ListSectors()
if err != nil {
return nil, err
}
sectorStats := sm.Miner.SectorsSummary(ctx)
out := make(map[api.SectorState]int)
for i := range sectors {
state := api.SectorState(sectors[i].State)
out[state]++
for st, count := range sectorStats {
state := api.SectorState(st)
out[state] = int(count)
}
return out, nil

View File

@ -304,6 +304,10 @@ 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) TerminateFlush(ctx context.Context) (*cid.Cid, error) {
return m.terminator.Flush(ctx)
}