lotus/storage/paths/interface.go

55 lines
2.8 KiB
Go
Raw Normal View History

package paths
2020-03-23 11:40:02 +00:00
import (
"context"
"io"
2024-01-12 10:03:37 +00:00
"github.com/ipfs/go-cid"
2023-05-23 09:59:40 +00:00
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/partialfile"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)
//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.
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.
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
}
//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 {
AcquireSector(ctx context.Context, s storiface.SectorRef, existing storiface.SectorFileType, allocate storiface.SectorFileType, sealing storiface.PathType, op storiface.AcquireMode, opts ...storiface.AcquireOption) (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
// 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
// move sectors into storage
MoveStorage(ctx context.Context, s storiface.SectorRef, types storiface.SectorFileType, opts ...storiface.AcquireOption) error
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
Reserve(ctx context.Context, sid storiface.SectorRef, ft storiface.SectorFileType, storageIDs storiface.SectorPaths, overheadTab map[storiface.SectorFileType]int, minFreePercentage float64) (func(), error)
2022-01-14 13:11:04 +00:00
GenerateSingleVanillaProof(ctx context.Context, minerID abi.ActorID, si storiface.PostSectorChallenge, ppt abi.RegisteredPoStProof) ([]byte, error)
GeneratePoRepVanillaProof(ctx context.Context, sr storiface.SectorRef, sealed, unsealed cid.Cid, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness) ([]byte, error)
}