lotus/extern/sector-storage/stores/interface.go

48 lines
2.1 KiB
Go
Raw Normal View History

2020-03-23 11:40:02 +00:00
package stores
import (
"context"
2021-05-20 11:01:25 +00:00
"os"
2020-11-16 18:20:18 +00:00
2020-09-07 03:49:10 +00:00
"github.com/filecoin-project/go-state-types/abi"
2021-05-19 13:50:48 +00:00
"github.com/filecoin-project/lotus/extern/sector-storage/partialfile"
2020-03-23 11:40:02 +00:00
"github.com/filecoin-project/specs-storage/storage"
2020-09-06 16:54:00 +00:00
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
)
2021-05-19 13:50:48 +00:00
// PartialFileHandler helps mock out the partial file functionality during testing.
type partialFileHandler interface {
// 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) (*os.File, error)
// Close closes the partial file
Close(pf *partialfile.PartialFile) error
2021-05-19 13:50:48 +00:00
}
2020-03-23 11:40:02 +00:00
type Store interface {
AcquireSector(ctx context.Context, s storage.SectorRef, existing storiface.SectorFileType, allocate storiface.SectorFileType, sealing storiface.PathType, op storiface.AcquireMode) (paths storiface.SectorPaths, stores storiface.SectorPaths, err error)
2020-09-06 16:54:00 +00:00
Remove(ctx context.Context, s abi.SectorID, types storiface.SectorFileType, force bool) 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 storage.SectorRef, types storiface.SectorFileType) error
2020-07-08 14:58:09 +00:00
FsStat(ctx context.Context, id ID) (fsutil.FsStat, error)
2021-05-20 05:08:22 +00:00
Reserve(ctx context.Context, sid storage.SectorRef, ft storiface.SectorFileType, storageIDs storiface.SectorPaths, overheadTab map[storiface.SectorFileType]int) (func(), error)
}