address review
This commit is contained in:
parent
5dfec4ab36
commit
6ca55d18a7
@ -175,6 +175,8 @@ func (p *ParkPieceTask) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParkPieceTask) TypeDetails() harmonytask.TaskTypeDetails {
|
func (p *ParkPieceTask) TypeDetails() harmonytask.TaskTypeDetails {
|
||||||
|
const maxSizePiece = 64 << 30
|
||||||
|
|
||||||
return harmonytask.TaskTypeDetails{
|
return harmonytask.TaskTypeDetails{
|
||||||
Max: p.max,
|
Max: p.max,
|
||||||
Name: "ParkPiece",
|
Name: "ParkPiece",
|
||||||
@ -182,12 +184,35 @@ func (p *ParkPieceTask) TypeDetails() harmonytask.TaskTypeDetails {
|
|||||||
Cpu: 1,
|
Cpu: 1,
|
||||||
Gpu: 0,
|
Gpu: 0,
|
||||||
Ram: 64 << 20,
|
Ram: 64 << 20,
|
||||||
Storage: nil, // TODO
|
Storage: p.sc.Storage(p.taskToRef, storiface.FTPiece, storiface.FTNone, maxSizePiece, storiface.PathSealing),
|
||||||
},
|
},
|
||||||
MaxFailures: 10,
|
MaxFailures: 10,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *ParkPieceTask) taskToRef(id harmonytask.TaskID) (lpffi.SectorRef, error) {
|
||||||
|
var pieceIDs []struct {
|
||||||
|
ID storiface.PieceNumber `db:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := p.db.Select(context.Background(), &pieceIDs, `SELECT id FROM parked_pieces WHERE task_id = $1`, id)
|
||||||
|
if err != nil {
|
||||||
|
return lpffi.SectorRef{}, xerrors.Errorf("getting piece id: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(pieceIDs) != 1 {
|
||||||
|
return lpffi.SectorRef{}, xerrors.Errorf("expected 1 piece id, got %d", len(pieceIDs))
|
||||||
|
}
|
||||||
|
|
||||||
|
pref := pieceIDs[0].ID.Ref()
|
||||||
|
|
||||||
|
return lpffi.SectorRef{
|
||||||
|
SpID: int64(pref.ID.Miner),
|
||||||
|
SectorNumber: int64(pref.ID.Number),
|
||||||
|
RegSealProof: pref.ProofType,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *ParkPieceTask) Adder(taskFunc harmonytask.AddTaskFunc) {
|
func (p *ParkPieceTask) Adder(taskFunc harmonytask.AddTaskFunc) {
|
||||||
p.TF.Set(taskFunc)
|
p.TF.Set(taskFunc)
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,6 @@ func (s *SDRTask) getTicket(ctx context.Context, maddr address.Address) (abi.Sea
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SDRTask) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.TaskEngine) (*harmonytask.TaskID, error) {
|
func (s *SDRTask) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.TaskEngine) (*harmonytask.TaskID, error) {
|
||||||
// todo check storage (reserve too?)
|
|
||||||
|
|
||||||
id := ids[0]
|
id := ids[0]
|
||||||
return &id, nil
|
return &id, nil
|
||||||
}
|
}
|
||||||
|
@ -747,6 +747,8 @@ func (r *Remote) Reader(ctx context.Context, s storiface.SectorRef, offset, size
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReaderSeq creates a simple sequential reader for a file. Does not work for
|
||||||
|
// file types which are a directory (e.g. FTCache).
|
||||||
func (r *Remote) ReaderSeq(ctx context.Context, s storiface.SectorRef, ft storiface.SectorFileType) (io.ReadCloser, error) {
|
func (r *Remote) ReaderSeq(ctx context.Context, s storiface.SectorRef, ft storiface.SectorFileType) (io.ReadCloser, error) {
|
||||||
paths, _, err := r.local.AcquireSector(ctx, s, ft, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove)
|
paths, _, err := r.local.AcquireSector(ctx, s, ft, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user