retrieval: address some review comments

This commit is contained in:
Łukasz Magiera 2019-08-29 20:55:20 +02:00
parent f79b755c58
commit 83748b40b6
3 changed files with 7 additions and 4 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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) {