2019-11-01 12:01:16 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-11-01 13:58:48 +00:00
|
|
|
"fmt"
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/chain/address"
|
|
|
|
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
|
|
|
)
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
// alias because cbor-gen doesn't like non-alias types
|
|
|
|
type SectorState = uint64
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
const (
|
2019-11-01 13:58:48 +00:00
|
|
|
UndefinedSectorState SectorState = iota
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
Empty // TODO: Is this useful
|
|
|
|
Packing // sector not in sealStore, and not on chain
|
|
|
|
|
|
|
|
Unsealed // sealing / queued
|
|
|
|
PreCommitting // on chain pre-commit
|
|
|
|
PreCommitted // waiting for seed
|
|
|
|
Committing
|
2019-11-01 13:58:48 +00:00
|
|
|
Proving
|
|
|
|
|
|
|
|
SectorNoUpdate = UndefinedSectorState
|
2019-11-01 12:01:16 +00:00
|
|
|
)
|
|
|
|
|
2019-11-01 13:58:48 +00:00
|
|
|
func SectorStateStr(s SectorState) string {
|
|
|
|
switch s {
|
|
|
|
case UndefinedSectorState:
|
|
|
|
return "UndefinedSectorState"
|
|
|
|
case Empty:
|
|
|
|
return "Empty"
|
|
|
|
case Packing:
|
|
|
|
return "Packing"
|
|
|
|
case Unsealed:
|
|
|
|
return "Unsealed"
|
|
|
|
case PreCommitting:
|
|
|
|
return "PreCommitting"
|
|
|
|
case PreCommitted:
|
|
|
|
return "PreCommitted"
|
|
|
|
case Committing:
|
|
|
|
return "Committing"
|
|
|
|
case Proving:
|
|
|
|
return "Proving"
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("<Unknown %d>", s)
|
|
|
|
}
|
|
|
|
|
2019-11-01 12:01:16 +00:00
|
|
|
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
|
|
|
type StorageMiner interface {
|
|
|
|
Common
|
|
|
|
|
|
|
|
ActorAddress(context.Context) (address.Address, error)
|
|
|
|
|
|
|
|
// Temp api for testing
|
|
|
|
StoreGarbageData(context.Context) error
|
|
|
|
|
|
|
|
// Get the status of a given sector by ID
|
2019-11-08 18:15:13 +00:00
|
|
|
SectorsStatus(context.Context, uint64) (SectorInfo, error)
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
// List all staged sectors
|
|
|
|
SectorsList(context.Context) ([]uint64, error)
|
|
|
|
|
|
|
|
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
2019-11-08 18:15:13 +00:00
|
|
|
|
|
|
|
WorkerStats(context.Context) (WorkerStats, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type WorkerStats struct {
|
|
|
|
Free int
|
|
|
|
Reserved int // for PoSt
|
|
|
|
Total int
|
|
|
|
}
|
|
|
|
|
|
|
|
type SectorInfo struct {
|
|
|
|
SectorID uint64
|
|
|
|
State SectorState
|
|
|
|
CommD []byte
|
|
|
|
CommR []byte
|
|
|
|
Proof []byte
|
|
|
|
Deals []uint64
|
|
|
|
Ticket sectorbuilder.SealTicket
|
|
|
|
Seed sectorbuilder.SealSeed
|
2019-11-01 12:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SealedRef struct {
|
2019-12-01 17:58:31 +00:00
|
|
|
SectorID uint64
|
|
|
|
Offset uint64
|
|
|
|
Size uint64
|
2019-11-06 12:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SealedRefs struct {
|
|
|
|
Refs []SealedRef
|
2019-11-01 12:01:16 +00:00
|
|
|
}
|