2019-11-01 12:01:16 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-12-04 13:10:15 +00:00
|
|
|
|
2019-12-19 20:13:17 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2019-12-19 21:06:25 +00:00
|
|
|
"github.com/filecoin-project/go-sectorbuilder"
|
2019-11-01 12:01:16 +00:00
|
|
|
)
|
|
|
|
|
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
|
|
|
|
2020-01-13 20:54:28 +00:00
|
|
|
// happy path
|
|
|
|
Empty
|
2019-11-01 12:01:16 +00:00
|
|
|
Packing // sector not in sealStore, and not on chain
|
|
|
|
|
|
|
|
Unsealed // sealing / queued
|
|
|
|
PreCommitting // on chain pre-commit
|
2020-01-20 22:04:46 +00:00
|
|
|
WaitSeed // waiting for seed
|
2019-11-01 12:01:16 +00:00
|
|
|
Committing
|
2019-12-06 02:40:57 +00:00
|
|
|
CommitWait // waiting for message to land on chain
|
2019-11-01 13:58:48 +00:00
|
|
|
Proving
|
2020-01-13 20:54:28 +00:00
|
|
|
_ // reserved
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
|
|
|
|
// recovery handling
|
|
|
|
// Reseal
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
|
|
|
|
// error modes
|
|
|
|
FailedUnrecoverable
|
2019-11-01 13:58:48 +00:00
|
|
|
|
2019-12-03 23:59:40 +00:00
|
|
|
SealFailed
|
|
|
|
PreCommitFailed
|
|
|
|
SealCommitFailed
|
|
|
|
CommitFailed
|
2020-01-22 19:47:29 +00:00
|
|
|
PackingFailed
|
2020-01-13 20:54:28 +00:00
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
2019-12-06 14:06:42 +00:00
|
|
|
|
|
|
|
Faulty // sector is corrupted or gone for some reason
|
|
|
|
FaultReported // sector has been declared as a fault on chain
|
|
|
|
FaultedFinal // fault declared on chain
|
2019-11-01 12:01:16 +00:00
|
|
|
)
|
|
|
|
|
2019-12-03 23:42:22 +00:00
|
|
|
var SectorStates = []string{
|
|
|
|
UndefinedSectorState: "UndefinedSectorState",
|
2019-12-03 23:59:40 +00:00
|
|
|
Empty: "Empty",
|
|
|
|
Packing: "Packing",
|
|
|
|
Unsealed: "Unsealed",
|
|
|
|
PreCommitting: "PreCommitting",
|
2020-01-20 22:04:46 +00:00
|
|
|
WaitSeed: "WaitSeed",
|
2019-12-03 23:59:40 +00:00
|
|
|
Committing: "Committing",
|
2019-12-06 14:06:42 +00:00
|
|
|
CommitWait: "CommitWait",
|
2019-12-03 23:59:40 +00:00
|
|
|
Proving: "Proving",
|
|
|
|
|
|
|
|
SealFailed: "SealFailed",
|
|
|
|
PreCommitFailed: "PreCommitFailed",
|
|
|
|
SealCommitFailed: "SealCommitFailed",
|
|
|
|
CommitFailed: "CommitFailed",
|
|
|
|
|
2019-12-03 23:42:22 +00:00
|
|
|
FailedUnrecoverable: "FailedUnrecoverable",
|
2019-12-06 14:06:42 +00:00
|
|
|
|
|
|
|
Faulty: "Faulty",
|
|
|
|
FaultReported: "FaultReported",
|
|
|
|
FaultedFinal: "FaultedFinal",
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
2019-11-21 14:10:51 +00:00
|
|
|
ActorSectorSize(context.Context, address.Address) (uint64, error)
|
|
|
|
|
2019-11-01 12:01:16 +00:00
|
|
|
// Temp api for testing
|
2019-12-08 21:48:20 +00:00
|
|
|
PledgeSector(context.Context) error
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2019-12-05 04:43:54 +00:00
|
|
|
SectorsUpdate(context.Context, uint64, SectorState) error
|
|
|
|
|
2019-11-21 16:23:42 +00:00
|
|
|
WorkerStats(context.Context) (sectorbuilder.WorkerStats, error)
|
2019-11-21 00:52:59 +00:00
|
|
|
|
|
|
|
// WorkerQueue registers a remote worker
|
2019-12-06 00:27:32 +00:00
|
|
|
WorkerQueue(context.Context, sectorbuilder.WorkerCfg) (<-chan sectorbuilder.WorkerTask, error)
|
2019-11-21 00:52:59 +00:00
|
|
|
|
|
|
|
WorkerDone(ctx context.Context, task uint64, res sectorbuilder.SealRes) error
|
2019-11-08 18:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SectorInfo struct {
|
|
|
|
SectorID uint64
|
|
|
|
State SectorState
|
|
|
|
CommD []byte
|
|
|
|
CommR []byte
|
|
|
|
Proof []byte
|
|
|
|
Deals []uint64
|
|
|
|
Ticket sectorbuilder.SealTicket
|
|
|
|
Seed sectorbuilder.SealSeed
|
2019-12-09 16:40:15 +00:00
|
|
|
Retries uint64
|
2019-12-08 16:10:11 +00:00
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
LastErr string
|
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
|
|
|
}
|