diff --git a/retrieval/miner.go b/retrieval/miner.go index bc1a95886..434ccfab3 100644 --- a/retrieval/miner.go +++ b/retrieval/miner.go @@ -121,6 +121,8 @@ func (hnd *handlerDeal) handleNext() (bool, error) { // TODO: Verify payment, check how much we can send based on that // Or reject (possibly returning the payment to retain reputation with the client) + // If the file isn't open (new deal stream), isn't the right file, or isn't + // at the right offset, (re)open it if hnd.open != deal.Ref || hnd.at != unixfs0.Offset { log.Infof("opening file for sending (open '%s') (@%d, want %d)", hnd.open, hnd.at, unixfs0.Offset) if err := hnd.openFile(deal); err != nil { diff --git a/retrieval/types.go b/retrieval/types.go index 968c5eaad..145b06732 100644 --- a/retrieval/types.go +++ b/retrieval/types.go @@ -25,12 +25,13 @@ const ( ) func init() { - cbor.RegisterCborType(DealProposal{}) + cbor.RegisterCborType(RetParams{}) cbor.RegisterCborType(Query{}) cbor.RegisterCborType(QueryResponse{}) cbor.RegisterCborType(Unixfs0Offer{}) + cbor.RegisterCborType(DealProposal{}) cbor.RegisterCborType(DealResponse{}) cbor.RegisterCborType(Block{}) } @@ -50,7 +51,7 @@ type QueryResponse struct { MinPrice types.BigInt } -type Unixfs0Offer struct { // UNBORK +type Unixfs0Offer struct { Offset uint64 Size uint64 } diff --git a/storage/sectorblocks/unsealed.go b/storage/sectorblocks/unsealed.go index d532b82ab..042e2c931 100644 --- a/storage/sectorblocks/unsealed.go +++ b/storage/sectorblocks/unsealed.go @@ -31,7 +31,7 @@ func (ub *unsealedBlocks) getRef(ctx context.Context, refs []api.SealedRef, appr b, ok := ub.unsealed[ref.Piece] if ok { ub.lk.Unlock() - return b[ref.Offset : ref.Offset+uint64(ref.Size)], nil // TODO: check slice math + return b[ref.Offset : ref.Offset+uint64(ref.Size)], nil } // TODO: pick unsealing based on how long it's running (or just select all relevant, usually it'll be just one) _, ok = ub.unsealing[ref.Piece] @@ -48,7 +48,7 @@ func (ub *unsealedBlocks) getRef(ctx context.Context, refs []api.SealedRef, appr return nil, err } - return b[best.Offset : best.Offset+uint64(best.Size)], nil // TODO: check slice math + return b[best.Offset : best.Offset+uint64(best.Size)], nil } func (ub *unsealedBlocks) maybeUnseal(ctx context.Context, pieceKey string, approveUnseal func() error) ([]byte, error) {