From 8f70192bf3f4adcb10b6f80d01dbef197bdbf205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 19 May 2020 18:11:56 +0200 Subject: [PATCH] Missing stuff --- ffiwrapper/unseal_ranges.go | 24 ++++++++++++++++++++++++ storiface/ffi.go | 5 +++++ 2 files changed, 29 insertions(+) create mode 100644 ffiwrapper/unseal_ranges.go create mode 100644 storiface/ffi.go diff --git a/ffiwrapper/unseal_ranges.go b/ffiwrapper/unseal_ranges.go new file mode 100644 index 000000000..873ac45d0 --- /dev/null +++ b/ffiwrapper/unseal_ranges.go @@ -0,0 +1,24 @@ +package ffiwrapper + +import ( + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-bitfield/rle" + "github.com/filecoin-project/specs-actors/actors/abi" +) + +// merge gaps between ranges which are close to each other +// TODO: more benchmarking to come up with more optimal number +const mergeGaps = 32 << 20 + +// TODO const expandRuns = 16 << 20 // unseal more than requested for future requests + +func computeUnsealRanges(unsealed rlepluslazy.RunIterator, offset UnpaddedByteIndex, size abi.UnpaddedPieceSize) (rlepluslazy.RunIterator, error) { + todo := pieceRun(offset, size) + todo, err := rlepluslazy.Subtract(todo, unsealed) + if err != nil { + return nil, xerrors.Errorf("compute todo-unsealed: %w", err) + } + + return rlepluslazy.JoinClose(todo, mergeGaps) +} diff --git a/storiface/ffi.go b/storiface/ffi.go new file mode 100644 index 000000000..354b1e9c4 --- /dev/null +++ b/storiface/ffi.go @@ -0,0 +1,5 @@ +package storiface + +import "errors" + +var ErrSectorNotFound = errors.New("sector not found")