2020-03-04 02:24:08 +00:00
|
|
|
package advmgr
|
|
|
|
|
|
|
|
import (
|
2020-03-06 05:30:47 +00:00
|
|
|
"context"
|
|
|
|
|
2020-03-04 02:24:08 +00:00
|
|
|
"github.com/filecoin-project/go-sectorbuilder"
|
2020-03-11 07:22:21 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/sealmgr/stores"
|
|
|
|
|
2020-03-04 02:24:08 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
)
|
|
|
|
|
|
|
|
type readonlyProvider struct {
|
|
|
|
miner abi.ActorID
|
2020-03-11 07:22:21 +00:00
|
|
|
stor *stores.Local
|
2020-03-04 02:24:08 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 05:30:47 +00:00
|
|
|
func (l *readonlyProvider) AcquireSector(ctx context.Context, id abi.SectorNumber, existing sectorbuilder.SectorFileType, allocate sectorbuilder.SectorFileType, sealing bool) (sectorbuilder.SectorPaths, func(), error) {
|
2020-03-04 02:24:08 +00:00
|
|
|
if allocate != 0 {
|
|
|
|
return sectorbuilder.SectorPaths{}, nil, xerrors.New("read-only storage")
|
|
|
|
}
|
|
|
|
|
2020-03-11 07:22:21 +00:00
|
|
|
return l.stor.AcquireSector(abi.SectorID{
|
|
|
|
Miner: l.miner,
|
|
|
|
Number: id,
|
|
|
|
}, existing, allocate, sealing)
|
2020-03-04 02:24:08 +00:00
|
|
|
}
|