Commit 99304d84 authored by Łukasz Magiera's avatar Łukasz Magiera
Browse files

CanCommit Method

parent af914f02
......@@ -81,6 +81,21 @@ func (sb *SectorBuilder) TrimCache(sectorID uint64) error {
return nil
}
func (sb *SectorBuilder) CanCommit(sectorID uint64) (bool, error) {
dir, err := sb.sectorCacheDir(sectorID)
if err != nil {
return false, xerrors.Errorf("getting cache dir: %w", err)
}
ents, err := ioutil.ReadDir(dir)
if err != nil {
return false, err
}
// TODO: slightly more sophisticated check
return len(ents) == 10, nil
}
func toReadableFile(r io.Reader, n int64) (*os.File, func() error, error) {
f, ok := r.(*os.File)
if ok {
......
......@@ -24,6 +24,7 @@ type Interface interface {
ReadPieceFromSealedSector(sectorID uint64, offset uint64, size uint64, ticket []byte, commD []byte) (io.ReadCloser, error)
GetPath(string, string) (string, error)
CanCommit(sectorID uint64) (bool, error)
WorkerStats() WorkerStats
AddWorker(context.Context, WorkerCfg) (<-chan WorkerTask, error)
TaskDone(context.Context, uint64, SealRes) error
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment