2022-06-14 18:25:52 +00:00
|
|
|
package paths
|
2020-03-23 11:40:02 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-01-11 15:46:47 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2023-05-19 12:33:35 +00:00
|
|
|
"io"
|
2020-11-04 20:29:08 +00:00
|
|
|
|
2023-05-23 09:59:40 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
|
2022-06-14 18:03:38 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
|
|
|
|
"github.com/filecoin-project/lotus/storage/sealer/partialfile"
|
2022-06-15 10:06:22 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
2020-05-20 16:36:46 +00:00
|
|
|
)
|
|
|
|
|
2021-10-11 19:05:05 +00:00
|
|
|
//go:generate go run github.com/golang/mock/mockgen -destination=mocks/pf.go -package=mocks . PartialFileHandler
|
|
|
|
|
2021-05-19 13:50:48 +00:00
|
|
|
// PartialFileHandler helps mock out the partial file functionality during testing.
|
2021-10-11 19:05:05 +00:00
|
|
|
type PartialFileHandler interface {
|
2021-05-19 13:50:48 +00:00
|
|
|
// OpenPartialFile opens and returns a partial file at the given path and also verifies it has the given
|
|
|
|
// size
|
|
|
|
OpenPartialFile(maxPieceSize abi.PaddedPieceSize, path string) (*partialfile.PartialFile, error)
|
|
|
|
|
2021-05-20 11:01:25 +00:00
|
|
|
// HasAllocated returns true if the given partial file has an unsealed piece starting at the given offset with the given size.
|
2021-05-19 13:50:48 +00:00
|
|
|
// returns false otherwise.
|
|
|
|
HasAllocated(pf *partialfile.PartialFile, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize) (bool, error)
|
2021-05-20 11:01:25 +00:00
|
|
|
|
|
|
|
// Reader returns a file from which we can read the unsealed piece in the partial file.
|
2023-05-19 12:33:35 +00:00
|
|
|
Reader(pf *partialfile.PartialFile, offset storiface.PaddedByteIndex, size abi.PaddedPieceSize) (io.Reader, error)
|
2021-05-20 11:01:25 +00:00
|
|
|
|
|
|
|
// Close closes the partial file
|
|
|
|
Close(pf *partialfile.PartialFile) error
|
2021-05-19 13:50:48 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 19:05:05 +00:00
|
|
|
//go:generate go run github.com/golang/mock/mockgen -destination=mocks/store.go -package=mocks . Store
|
|
|
|
|
2020-03-23 11:40:02 +00:00
|
|
|
type Store interface {
|
2022-06-17 11:31:05 +00:00
|
|
|
AcquireSector(ctx context.Context, s storiface.SectorRef, existing storiface.SectorFileType, allocate storiface.SectorFileType, sealing storiface.PathType, op storiface.AcquireMode) (paths storiface.SectorPaths, stores storiface.SectorPaths, err error)
|
2022-01-18 10:57:04 +00:00
|
|
|
Remove(ctx context.Context, s abi.SectorID, types storiface.SectorFileType, force bool, keepIn []storiface.ID) error
|
2020-03-25 18:21:53 +00:00
|
|
|
|
2020-05-20 16:36:46 +00:00
|
|
|
// like remove, but doesn't remove the primary sector copy, nor the last
|
|
|
|
// non-primary copy if there no primary copies
|
2020-09-06 16:54:00 +00:00
|
|
|
RemoveCopies(ctx context.Context, s abi.SectorID, types storiface.SectorFileType) error
|
2020-05-20 16:36:46 +00:00
|
|
|
|
2020-03-25 18:21:53 +00:00
|
|
|
// move sectors into storage
|
2022-06-17 11:31:05 +00:00
|
|
|
MoveStorage(ctx context.Context, s storiface.SectorRef, types storiface.SectorFileType) error
|
2020-03-25 18:21:53 +00:00
|
|
|
|
2022-01-18 10:57:04 +00:00
|
|
|
FsStat(ctx context.Context, id storiface.ID) (fsutil.FsStat, error)
|
2021-05-20 05:08:22 +00:00
|
|
|
|
2022-06-17 11:31:05 +00:00
|
|
|
Reserve(ctx context.Context, sid storiface.SectorRef, ft storiface.SectorFileType, storageIDs storiface.SectorPaths, overheadTab map[storiface.SectorFileType]int) (func(), error)
|
2021-07-27 03:15:53 +00:00
|
|
|
|
2022-01-14 13:11:04 +00:00
|
|
|
GenerateSingleVanillaProof(ctx context.Context, minerID abi.ActorID, si storiface.PostSectorChallenge, ppt abi.RegisteredPoStProof) ([]byte, error)
|
2024-01-11 15:46:47 +00:00
|
|
|
GenetartePoRepVanillaProof(ctx context.Context, sr storiface.SectorRef, sealed, unsealed cid.Cid, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness) ([]byte, error)
|
2020-03-23 22:43:38 +00:00
|
|
|
}
|