2019-11-01 12:01:16 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2020-03-03 22:19:22 +00:00
|
|
|
"bytes"
|
2019-11-01 12:01:16 +00:00
|
|
|
"context"
|
2019-12-04 13:10:15 +00:00
|
|
|
|
2020-03-03 00:45:32 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
|
2019-12-19 20:13:17 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2020-03-13 11:59:19 +00:00
|
|
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
2020-02-08 02:18:32 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
|
|
|
2020-02-08 00:18:14 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2020-03-27 23:00:21 +00:00
|
|
|
"github.com/filecoin-project/sector-storage"
|
|
|
|
"github.com/filecoin-project/sector-storage/stores"
|
2019-11-01 12:01:16 +00:00
|
|
|
)
|
|
|
|
|
2020-04-03 16:24:45 +00:00
|
|
|
type SectorState string
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
const (
|
2020-04-03 16:24:45 +00:00
|
|
|
UndefinedSectorState SectorState = ""
|
2019-11-01 12:01:16 +00:00
|
|
|
|
2020-01-13 20:54:28 +00:00
|
|
|
// happy path
|
2020-04-03 16:24:45 +00:00
|
|
|
Empty SectorState = "Empty"
|
|
|
|
Packing SectorState = "Packing" // sector not in sealStore, and not on chain
|
2020-04-03 16:54:01 +00:00
|
|
|
PreCommit1 SectorState = "PreCommit1" // do PreCommit1
|
|
|
|
PreCommit2 SectorState = "PreCommit2" // do PreCommit1
|
2020-04-03 16:24:45 +00:00
|
|
|
PreCommitting SectorState = "PreCommitting" // on chain pre-commit
|
|
|
|
WaitSeed SectorState = "WaitSeed" // waiting for seed
|
|
|
|
Committing SectorState = "Committing"
|
|
|
|
CommitWait SectorState = "CommitWait" // waiting for message to land on chain
|
|
|
|
FinalizeSector SectorState = "FinalizeSector"
|
|
|
|
Proving SectorState = "Proving"
|
2020-01-13 20:54:28 +00:00
|
|
|
// error modes
|
2020-04-03 16:24:45 +00:00
|
|
|
FailedUnrecoverable SectorState = "FailedUnrecoverable"
|
|
|
|
SealFailed SectorState = "SealFailed"
|
|
|
|
PreCommitFailed SectorState = "PreCommitFailed"
|
2020-04-03 17:45:48 +00:00
|
|
|
ComputeProofFailed SectorState = "ComputeProofFailed"
|
2020-04-03 16:24:45 +00:00
|
|
|
CommitFailed SectorState = "CommitFailed"
|
|
|
|
PackingFailed SectorState = "PackingFailed"
|
|
|
|
Faulty SectorState = "Faulty" // sector is corrupted or gone for some reason
|
|
|
|
FaultReported SectorState = "FaultReported" // sector has been declared as a fault on chain
|
|
|
|
FaultedFinal SectorState = "FaultedFinal" // fault declared on chain
|
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)
|
|
|
|
|
2020-02-09 06:06:32 +00:00
|
|
|
ActorSectorSize(context.Context, address.Address) (abi.SectorSize, error)
|
2019-11-21 14:10:51 +00:00
|
|
|
|
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
|
2020-02-09 06:06:32 +00:00
|
|
|
SectorsStatus(context.Context, abi.SectorNumber) (SectorInfo, error)
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
// List all staged sectors
|
2020-02-09 06:06:32 +00:00
|
|
|
SectorsList(context.Context) ([]abi.SectorNumber, error)
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
2019-11-08 18:15:13 +00:00
|
|
|
|
2020-02-09 06:06:32 +00:00
|
|
|
SectorsUpdate(context.Context, abi.SectorNumber, SectorState) error
|
2019-12-05 04:43:54 +00:00
|
|
|
|
2020-03-16 17:50:07 +00:00
|
|
|
StorageList(ctx context.Context) (map[stores.ID][]stores.Decl, error)
|
2020-03-19 19:51:33 +00:00
|
|
|
StorageLocal(ctx context.Context) (map[stores.ID]string, error)
|
2020-03-23 22:43:38 +00:00
|
|
|
StorageStat(ctx context.Context, id stores.ID) (stores.FsStat, error)
|
2020-03-16 17:50:07 +00:00
|
|
|
|
2020-03-11 01:57:52 +00:00
|
|
|
// WorkerConnect tells the node to connect to workers RPC
|
|
|
|
WorkerConnect(context.Context, string) error
|
2020-03-27 20:08:06 +00:00
|
|
|
WorkerStats(context.Context) (map[uint64]sectorstorage.WorkerStats, error)
|
2020-03-23 14:56:22 +00:00
|
|
|
|
2020-03-13 11:59:19 +00:00
|
|
|
stores.SectorIndex
|
2019-11-21 00:52:59 +00:00
|
|
|
|
2020-02-08 00:18:14 +00:00
|
|
|
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error
|
|
|
|
MarketListDeals(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
|
|
|
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error)
|
2020-03-24 18:00:08 +00:00
|
|
|
MarketSetPrice(context.Context, types.BigInt) error
|
2020-03-04 02:49:00 +00:00
|
|
|
|
|
|
|
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
|
|
|
|
DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
2020-03-05 22:02:01 +00:00
|
|
|
|
|
|
|
StorageAddLocal(ctx context.Context, path string) error
|
2020-02-28 18:06:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SealRes struct {
|
|
|
|
Err string
|
|
|
|
GoErr error `json:"-"`
|
2019-11-21 00:52:59 +00:00
|
|
|
|
2020-02-28 18:06:59 +00:00
|
|
|
Proof []byte
|
2019-11-08 18:15:13 +00:00
|
|
|
}
|
|
|
|
|
2020-01-23 14:18:05 +00:00
|
|
|
type SectorLog struct {
|
|
|
|
Kind string
|
|
|
|
Timestamp uint64
|
|
|
|
|
|
|
|
Trace string
|
|
|
|
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2019-11-08 18:15:13 +00:00
|
|
|
type SectorInfo struct {
|
2020-02-09 06:06:32 +00:00
|
|
|
SectorID abi.SectorNumber
|
2019-11-08 18:15:13 +00:00
|
|
|
State SectorState
|
2020-02-27 21:45:31 +00:00
|
|
|
CommD *cid.Cid
|
|
|
|
CommR *cid.Cid
|
2019-11-08 18:15:13 +00:00
|
|
|
Proof []byte
|
2020-02-09 06:06:32 +00:00
|
|
|
Deals []abi.DealID
|
2020-03-03 22:19:22 +00:00
|
|
|
Ticket SealTicket
|
|
|
|
Seed 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
|
2020-01-23 14:18:05 +00:00
|
|
|
|
|
|
|
Log []SectorLog
|
2019-11-01 12:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SealedRef struct {
|
2020-02-08 02:18:32 +00:00
|
|
|
SectorID abi.SectorNumber
|
2019-12-01 17:58:31 +00:00
|
|
|
Offset uint64
|
2020-02-08 02:18:32 +00:00
|
|
|
Size abi.UnpaddedPieceSize
|
2019-11-06 12:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SealedRefs struct {
|
|
|
|
Refs []SealedRef
|
2019-11-01 12:01:16 +00:00
|
|
|
}
|
2020-03-03 22:19:22 +00:00
|
|
|
|
|
|
|
type SealTicket struct {
|
|
|
|
Value abi.SealRandomness
|
|
|
|
Epoch abi.ChainEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
type SealSeed struct {
|
|
|
|
Value abi.InteractiveSealRandomness
|
|
|
|
Epoch abi.ChainEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
func (st *SealTicket) Equals(ost *SealTicket) bool {
|
|
|
|
return bytes.Equal(st.Value, ost.Value) && st.Epoch == ost.Epoch
|
|
|
|
}
|
|
|
|
|
|
|
|
func (st *SealSeed) Equals(ost *SealSeed) bool {
|
|
|
|
return bytes.Equal(st.Value, ost.Value) && st.Epoch == ost.Epoch
|
2020-03-05 19:21:06 +00:00
|
|
|
}
|