Skip to content

Commit

Permalink
fix : retrieval market: retrieval provider begins data transfer in in…
Browse files Browse the repository at this point in the history
…correct state. (#146)

* fix retrieval provider transfer data without waiting payment
  • Loading branch information
zl03jsj authored Jun 15, 2022
1 parent b042e39 commit 3d7166c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion retrievalprovider/datatransfer_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package retrievalprovider

import (
"context"
"fmt"

datatransfer "github.com/filecoin-project/go-data-transfer"
rm "github.com/filecoin-project/go-fil-markets/retrievalmarket"
Expand Down Expand Up @@ -43,8 +44,21 @@ func (d *DataTransferHandler) HandleAcceptFor(ctx context.Context, identifier rm
if err != nil {
return err
}
// state transition should follow `ProviderEventDealAccepted` event
// https://github.com/filecoin-project/go-fil-markets/blob/9e5f2499cba68968ffc75a22b89a085c5722f1a5/retrievalmarket/impl/providerstates/provider_fsm.go#L32-L38
deal.ChannelID = &channelId
return d.retrievalDealHandler.UnsealData(ctx, deal)
if err = d.retrievalDealStore.SaveDeal(ctx, deal); err != nil {
return err
}

switch deal.Status {
case rm.DealStatusFundsNeededUnseal: // nothing needs to do.
return nil
case rm.DealStatusNew:
return d.retrievalDealHandler.UnsealData(ctx, deal)
default:
return fmt.Errorf("invalid state transition, state `%+v`, event `%+v`", deal.Status, rm.ProviderEventDealAccepted)
}
}

func (d *DataTransferHandler) HandleDisconnectFor(ctx context.Context, identifier rm.ProviderDealIdentifier, errIn error) error {
Expand Down

0 comments on commit 3d7166c

Please sign in to comment.