Skip to content

Commit

Permalink
refactor: pass deal proposal instead of deal ID to OnDealExpiredOrSla…
Browse files Browse the repository at this point in the history
…shed (#476)
  • Loading branch information
dirkmc authored Aug 4, 2021
1 parent 52a5c62 commit 2e06ce3
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion storagemarket/impl/clientstates/client_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func WaitForDealCompletion(ctx fsm.Context, environment ClientDealEnvironment, d
}
}

if err := node.OnDealExpiredOrSlashed(ctx.Context(), deal.DealID, expiredCb, slashedCb); err != nil {
if err := node.OnDealExpiredOrSlashed(ctx.Context(), *deal.PublishMessage, deal.Proposal, expiredCb, slashedCb); err != nil {
return ctx.Trigger(storagemarket.ClientEventDealCompletionFailed, err)
}

Expand Down
1 change: 1 addition & 0 deletions storagemarket/impl/clientstates/client_states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func makeExecutor(ctx context.Context,
dealState, err := tut.MakeTestClientDeal(initialState, clientDealProposal, envParams.manualTransfer)
assert.NoError(t, err)
dealState.AddFundsCid = &tut.GenerateCids(1)[0]
dealState.PublishMessage = &tut.GenerateCids(1)[0]
dealState.FastRetrieval = dealParams.fastRetrieval
dealState.TransferChannelID = &datatransfer.ChannelID{}

Expand Down
2 changes: 1 addition & 1 deletion storagemarket/impl/providerstates/provider_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func WaitForDealCompletion(ctx fsm.Context, environment ProviderDealEnvironment,
}
}

if err := node.OnDealExpiredOrSlashed(ctx.Context(), deal.DealID, expiredCb, slashedCb); err != nil {
if err := node.OnDealExpiredOrSlashed(ctx.Context(), *deal.PublishCid, deal.Proposal, expiredCb, slashedCb); err != nil {
return ctx.Trigger(storagemarket.ProviderEventDealCompletionFailed, err)
}

Expand Down
2 changes: 1 addition & 1 deletion storagemarket/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type StorageCommon interface {
OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, sectorNumber abi.SectorNumber, proposal market.DealProposal, publishCid *cid.Cid, cb DealSectorCommittedCallback) error

// OnDealExpiredOrSlashed registers callbacks to be called when the deal expires or is slashed
OnDealExpiredOrSlashed(ctx context.Context, dealID abi.DealID, onDealExpired DealExpiredCallback, onDealSlashed DealSlashedCallback) error
OnDealExpiredOrSlashed(ctx context.Context, publishCid cid.Cid, proposal market.DealProposal, onDealExpired DealExpiredCallback, onDealSlashed DealSlashedCallback) error
}

// PackingResult returns information about how a deal was put into a sector
Expand Down
2 changes: 1 addition & 1 deletion storagemarket/testnodes/testnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (n *FakeCommonNode) OnDealSectorCommitted(ctx context.Context, provider add
}

// OnDealExpiredOrSlashed simulates waiting for a deal to be expired or slashed, but provides stubbed behavior
func (n *FakeCommonNode) OnDealExpiredOrSlashed(ctx context.Context, dealID abi.DealID, onDealExpired storagemarket.DealExpiredCallback, onDealSlashed storagemarket.DealSlashedCallback) error {
func (n *FakeCommonNode) OnDealExpiredOrSlashed(ctx context.Context, publishCid cid.Cid, proposal market.DealProposal, onDealExpired storagemarket.DealExpiredCallback, onDealSlashed storagemarket.DealSlashedCallback) error {
if n.DelayFakeCommonNode.OnDealExpiredOrSlashed {
select {
case <-ctx.Done():
Expand Down

0 comments on commit 2e06ce3

Please sign in to comment.