148 lines
3.1 KiB
Go
148 lines
3.1 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/filecoin-project/go-address"
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
|
|
"github.com/filecoin-project/go-sectorbuilder"
|
|
)
|
|
|
|
// alias because cbor-gen doesn't like non-alias types
|
|
type SectorState = uint64
|
|
|
|
const (
|
|
UndefinedSectorState SectorState = iota
|
|
|
|
// happy path
|
|
Empty
|
|
Packing // sector not in sealStore, and not on chain
|
|
|
|
Unsealed // sealing / queued
|
|
PreCommitting // on chain pre-commit
|
|
WaitSeed // waiting for seed
|
|
Committing
|
|
CommitWait // waiting for message to land on chain
|
|
FinalizeSector
|
|
Proving
|
|
_ // reserved
|
|
_
|
|
_
|
|
|
|
// recovery handling
|
|
// Reseal
|
|
_
|
|
_
|
|
_
|
|
_
|
|
_
|
|
_
|
|
_
|
|
|
|
// error modes
|
|
FailedUnrecoverable
|
|
|
|
SealFailed
|
|
PreCommitFailed
|
|
SealCommitFailed
|
|
CommitFailed
|
|
PackingFailed
|
|
_
|
|
_
|
|
_
|
|
|
|
Faulty // sector is corrupted or gone for some reason
|
|
FaultReported // sector has been declared as a fault on chain
|
|
FaultedFinal // fault declared on chain
|
|
)
|
|
|
|
var SectorStates = []string{
|
|
UndefinedSectorState: "UndefinedSectorState",
|
|
Empty: "Empty",
|
|
Packing: "Packing",
|
|
Unsealed: "Unsealed",
|
|
PreCommitting: "PreCommitting",
|
|
WaitSeed: "WaitSeed",
|
|
Committing: "Committing",
|
|
CommitWait: "CommitWait",
|
|
FinalizeSector: "FinalizeSector",
|
|
Proving: "Proving",
|
|
|
|
SealFailed: "SealFailed",
|
|
PreCommitFailed: "PreCommitFailed",
|
|
SealCommitFailed: "SealCommitFailed",
|
|
CommitFailed: "CommitFailed",
|
|
PackingFailed: "PackingFailed",
|
|
|
|
FailedUnrecoverable: "FailedUnrecoverable",
|
|
|
|
Faulty: "Faulty",
|
|
FaultReported: "FaultReported",
|
|
FaultedFinal: "FaultedFinal",
|
|
}
|
|
|
|
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
|
type StorageMiner interface {
|
|
Common
|
|
|
|
ActorAddress(context.Context) (address.Address, error)
|
|
|
|
ActorSectorSize(context.Context, address.Address) (abi.SectorSize, error)
|
|
|
|
// Temp api for testing
|
|
PledgeSector(context.Context) error
|
|
|
|
// Get the status of a given sector by ID
|
|
SectorsStatus(context.Context, abi.SectorNumber) (SectorInfo, error)
|
|
|
|
// List all staged sectors
|
|
SectorsList(context.Context) ([]abi.SectorNumber, error)
|
|
|
|
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
|
|
|
SectorsUpdate(context.Context, abi.SectorNumber, SectorState) error
|
|
|
|
WorkerStats(context.Context) (sectorbuilder.WorkerStats, error)
|
|
|
|
// WorkerQueue registers a remote worker
|
|
WorkerQueue(context.Context, sectorbuilder.WorkerCfg) (<-chan sectorbuilder.WorkerTask, error)
|
|
|
|
WorkerDone(ctx context.Context, task uint64, res sectorbuilder.SealRes) error
|
|
}
|
|
|
|
type SectorLog struct {
|
|
Kind string
|
|
Timestamp uint64
|
|
|
|
Trace string
|
|
|
|
Message string
|
|
}
|
|
|
|
type SectorInfo struct {
|
|
SectorID abi.SectorNumber
|
|
State SectorState
|
|
CommD []byte
|
|
CommR []byte
|
|
Proof []byte
|
|
Deals []abi.DealID
|
|
Ticket abi.SealRandomness
|
|
Seed abi.Randomness
|
|
Retries uint64
|
|
|
|
LastErr string
|
|
|
|
Log []SectorLog
|
|
}
|
|
|
|
type SealedRef struct {
|
|
SectorID abi.SectorNumber
|
|
Offset uint64
|
|
Size abi.UnpaddedPieceSize
|
|
}
|
|
|
|
type SealedRefs struct {
|
|
Refs []SealedRef
|
|
}
|