Skip to content

Commit

Permalink
fix restarts during data transfer for a retrieval deal (#540)
Browse files Browse the repository at this point in the history
* fix: restarts during data transfer for a retrieval deal

* fix: fire ClientEventPaymentNotSent when client receives request for payment but hasnt reached payment interval

* test: TestBounceConnectionDealTransferUnsealing

* fix: handle restart during unsealing

* feat: update to go-data-transfer v1.5.0
  • Loading branch information
dirkmc authored May 6, 2021
1 parent b080c6f commit ad3d7d3
Show file tree
Hide file tree
Showing 33 changed files with 1,360 additions and 478 deletions.
291 changes: 157 additions & 134 deletions docs/retrievalclient.mmd

Large diffs are not rendered by default.

Binary file modified docs/retrievalclient.mmd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/retrievalclient.mmd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 64 additions & 52 deletions docs/retrievalprovider.mmd
Original file line number Diff line number Diff line change
@@ -1,60 +1,72 @@
stateDiagram-v2
state "DealStatusNew" as 0
state "DealStatusUnsealing" as 1
state "DealStatusUnsealed" as 2
state "DealStatusFundsNeededUnseal" as 7
state "DealStatusFailing" as 8
state "DealStatusFundsNeeded" as 10
state "DealStatusOngoing" as 13
state "DealStatusFundsNeededLastPayment" as 14
state "DealStatusCompleted" as 15
state "DealStatusErrored" as 17
state "DealStatusBlocksComplete" as 18
state "DealStatusFinalizing" as 19
state "DealStatusCompleting" as 20
state "DealStatusCancelling" as 25
state "DealStatusCancelled" as 26
1 : On entry runs UnsealData
2 : On entry runs UnpauseDeal
7 : On entry runs TrackTransfer
8 : On entry runs CancelDeal
20 : On entry runs CleanupDeal
25 : On entry runs CancelDeal
[*] --> 0
note right of 0
state "DealStatusNew" as DealStatusNew
state "DealStatusUnsealing" as DealStatusUnsealing
state "DealStatusUnsealed" as DealStatusUnsealed
state "DealStatusFundsNeededUnseal" as DealStatusFundsNeededUnseal
state "DealStatusFailing" as DealStatusFailing
state "DealStatusFundsNeeded" as DealStatusFundsNeeded
state "DealStatusOngoing" as DealStatusOngoing
state "DealStatusFundsNeededLastPayment" as DealStatusFundsNeededLastPayment
state "DealStatusCompleted" as DealStatusCompleted
state "DealStatusErrored" as DealStatusErrored
state "DealStatusBlocksComplete" as DealStatusBlocksComplete
state "DealStatusFinalizing" as DealStatusFinalizing
state "DealStatusCompleting" as DealStatusCompleting
state "DealStatusCancelling" as DealStatusCancelling
state "DealStatusCancelled" as DealStatusCancelled
DealStatusUnsealing : On entry runs UnsealData
DealStatusUnsealed : On entry runs UnpauseDeal
DealStatusFundsNeededUnseal : On entry runs TrackTransfer
DealStatusFailing : On entry runs CancelDeal
DealStatusCompleting : On entry runs CleanupDeal
DealStatusCancelling : On entry runs CancelDeal
[*] --> DealStatusNew
note right of DealStatusNew
The following events are not shown cause they can trigger from any state.
ProviderEventDataTransferError - transitions state to DealStatusErrored
ProviderEventMultiStoreError - transitions state to DealStatusErrored
ProviderEventClientCancelled - transitions state to DealStatusCancelling
end note
0 --> 0 : ProviderEventOpen
0 --> 1 : ProviderEventDealAccepted
7 --> 7 : ProviderEventDealAccepted
1 --> 8 : ProviderEventUnsealError
1 --> 2 : ProviderEventUnsealComplete
2 --> 13 : ProviderEventBlockSent
13 --> 13 : ProviderEventBlockSent
13 --> 18 : ProviderEventBlocksCompleted
0 --> 7 : ProviderEventPaymentRequested
2 --> 10 : ProviderEventPaymentRequested
13 --> 10 : ProviderEventPaymentRequested
18 --> 14 : ProviderEventPaymentRequested
10 --> 8 : ProviderEventSaveVoucherFailed
14 --> 8 : ProviderEventSaveVoucherFailed
10 --> 10 : ProviderEventPartialPaymentReceived
14 --> 14 : ProviderEventPartialPaymentReceived
7 --> 1 : ProviderEventPaymentReceived
10 --> 13 : ProviderEventPaymentReceived
14 --> 19 : ProviderEventPaymentReceived
18 --> 20 : ProviderEventComplete
19 --> 20 : ProviderEventComplete
20 --> 15 : ProviderEventCleanupComplete
8 --> 17 : ProviderEventCancelComplete
25 --> 26 : ProviderEventCancelComplete

note left of 8 : The following events only record in this state.<br><br>ProviderEventClientCancelled


note left of 25 : The following events only record in this state.<br><br>ProviderEventClientCancelled
DealStatusNew --> DealStatusNew : ProviderEventOpen
DealStatusNew --> DealStatusUnsealing : ProviderEventDealAccepted
DealStatusFundsNeededUnseal --> DealStatusFundsNeededUnseal : ProviderEventDealAccepted
DealStatusUnsealing --> DealStatusFailing : ProviderEventUnsealError
DealStatusUnsealing --> DealStatusUnsealed : ProviderEventUnsealComplete
DealStatusUnsealed --> DealStatusOngoing : ProviderEventBlockSent
DealStatusOngoing --> DealStatusOngoing : ProviderEventBlockSent
DealStatusOngoing --> DealStatusBlocksComplete : ProviderEventBlocksCompleted
DealStatusNew --> DealStatusFundsNeededUnseal : ProviderEventPaymentRequested
DealStatusUnsealed --> DealStatusFundsNeeded : ProviderEventPaymentRequested
DealStatusOngoing --> DealStatusFundsNeeded : ProviderEventPaymentRequested
DealStatusBlocksComplete --> DealStatusFundsNeededLastPayment : ProviderEventPaymentRequested
DealStatusFundsNeeded --> DealStatusFailing : ProviderEventSaveVoucherFailed
DealStatusFundsNeededLastPayment --> DealStatusFailing : ProviderEventSaveVoucherFailed
DealStatusFundsNeeded --> DealStatusFundsNeeded : ProviderEventPartialPaymentReceived
DealStatusFundsNeededLastPayment --> DealStatusFundsNeededLastPayment : ProviderEventPartialPaymentReceived
DealStatusFundsNeededUnseal --> DealStatusUnsealing : ProviderEventPaymentReceived
DealStatusFundsNeeded --> DealStatusOngoing : ProviderEventPaymentReceived
DealStatusFundsNeededLastPayment --> DealStatusFinalizing : ProviderEventPaymentReceived
DealStatusBlocksComplete --> DealStatusCompleting : ProviderEventComplete
DealStatusFinalizing --> DealStatusCompleting : ProviderEventComplete
DealStatusCompleting --> DealStatusCompleted : ProviderEventCleanupComplete
DealStatusFailing --> DealStatusErrored : ProviderEventCancelComplete
DealStatusCancelling --> DealStatusCancelled : ProviderEventCancelComplete

note left of DealStatusFailing : The following events only record in this state.<br><br>ProviderEventClientCancelled


note left of DealStatusFundsNeeded : The following events only record in this state.<br><br>ProviderEventPaymentRequested


note left of DealStatusOngoing : The following events only record in this state.<br><br>ProviderEventPaymentReceived


note left of DealStatusBlocksComplete : The following events only record in this state.<br><br>ProviderEventPaymentReceived


note left of DealStatusFinalizing : The following events only record in this state.<br><br>ProviderEventPaymentReceived


note left of DealStatusCancelling : The following events only record in this state.<br><br>ProviderEventClientCancelled

Binary file modified docs/retrievalprovider.mmd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/retrievalprovider.mmd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/filecoin-project/go-address v0.0.3
github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2
github.com/filecoin-project/go-commp-utils v0.0.0-20201119054358-b88f7a96a434
github.com/filecoin-project/go-data-transfer v1.4.3
github.com/filecoin-project/go-data-transfer v1.5.0
github.com/filecoin-project/go-ds-versioning v0.1.0
github.com/filecoin-project/go-multistore v0.0.3
github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20
Expand All @@ -21,7 +21,7 @@ require (
github.com/ipfs/go-blockservice v0.1.4-0.20200624145336-a978cec6e834
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-datastore v0.4.5
github.com/ipfs/go-graphsync v0.6.0
github.com/ipfs/go-graphsync v0.6.1
github.com/ipfs/go-ipfs-blockstore v1.0.3
github.com/ipfs/go-ipfs-blocksutil v0.0.1
github.com/ipfs/go-ipfs-chunker v0.0.5
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo=
github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8=
github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
Expand Down Expand Up @@ -107,8 +109,8 @@ github.com/filecoin-project/go-commp-utils v0.0.0-20201119054358-b88f7a96a434/go
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 h1:2pMXdBnCiXjfCYx/hLqFxccPoqsSveQFxVLvNxy9bus=
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ=
github.com/filecoin-project/go-data-transfer v1.0.1/go.mod h1:UxvfUAY9v3ub0a21BSK9u3pB2aq30Y0KMsG+w9/ysyo=
github.com/filecoin-project/go-data-transfer v1.4.3 h1:ECEw69NOfmEZ7XN1NSBvj3KTbbH2mIczQs+Z2w4bD7c=
github.com/filecoin-project/go-data-transfer v1.4.3/go.mod h1:n8kbDQXWrY1c4UgfMa9KERxNCWbOTDwdNhf2MpN9dpo=
github.com/filecoin-project/go-data-transfer v1.5.0 h1:eXmcq7boRl/S3plV0/h4qdxkM6EgFIXF9y3UdOL0VXE=
github.com/filecoin-project/go-data-transfer v1.5.0/go.mod h1:E3WW4mCEYwU2y65swPEajSZoFWFmfXt7uwGduoACZQc=
github.com/filecoin-project/go-ds-versioning v0.1.0 h1:y/X6UksYTsK8TLCI7rttCKEvl8btmWxyFMEeeWGUxIQ=
github.com/filecoin-project/go-ds-versioning v0.1.0/go.mod h1:mp16rb4i2QPmxBnmanUx8i/XANp+PFCCJWiAb+VW4/s=
github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ=
Expand Down Expand Up @@ -283,8 +285,8 @@ github.com/ipfs/go-filestore v1.0.0/go.mod h1:/XOCuNtIe2f1YPbiXdYvD0BKLA0JR1MgPi
github.com/ipfs/go-graphsync v0.1.0/go.mod h1:jMXfqIEDFukLPZHqDPp8tJMbHO9Rmeb9CEGevngQbmE=
github.com/ipfs/go-graphsync v0.4.2/go.mod h1:/VmbZTUdUMTbNkgzAiCEucIIAU3BkLE2cZrDCVUhyi0=
github.com/ipfs/go-graphsync v0.4.3/go.mod h1:mPOwDYv128gf8gxPFgXnz4fNrSYPsWyqisJ7ych+XDY=
github.com/ipfs/go-graphsync v0.6.0 h1:x6UvDUGA7wjaKNqx5Vbo7FGT8aJ5ryYA0dMQ5jN3dF0=
github.com/ipfs/go-graphsync v0.6.0/go.mod h1:e2ZxnClqBBYAtd901g9vXMJzS47labjAtOzsWtOzKNk=
github.com/ipfs/go-graphsync v0.6.1 h1:i9wN7YkBXWwIsUjVQeuaDxFB59yWZrG1xL564Nz7aGE=
github.com/ipfs/go-graphsync v0.6.1/go.mod h1:e2ZxnClqBBYAtd901g9vXMJzS47labjAtOzsWtOzKNk=
github.com/ipfs/go-hamt-ipld v0.1.1/go.mod h1:1EZCr2v0jlCnhpa+aZ0JZYp8Tt2w16+JJOAVz17YcDk=
github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08=
github.com/ipfs/go-ipfs-blockstore v0.1.0/go.mod h1:5aD0AvHPi7mZc6Ci1WCAhiBQu2IsfTduLl+422H6Rqw=
Expand Down
10 changes: 10 additions & 0 deletions retrievalmarket/dealstatus.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package retrievalmarket

import "fmt"

// DealStatus is the status of a retrieval deal returned by a provider
// in a DealResponse
type DealStatus uint64
Expand Down Expand Up @@ -154,3 +156,11 @@ var DealStatuses = map[DealStatus]string{
DealStatusClientWaitingForLastBlocks: "DealStatusWaitingForLastBlocks",
DealStatusPaymentChannelAddingInitialFunds: "DealStatusPaymentChannelAddingInitialFunds",
}

func (s DealStatus) String() string {
str, ok := DealStatuses[s]
if ok {
return str
}
return fmt.Sprintf("DealStatusUnknown - %d", s)
}
18 changes: 17 additions & 1 deletion retrievalmarket/events.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package retrievalmarket

import "fmt"

// ClientEvent is an event that occurs in a deal lifecycle on the client
type ClientEvent uint64

Expand Down Expand Up @@ -86,7 +88,8 @@ const (
// ClientEventPaymentSent indicates a payment was sent to the provider
ClientEventPaymentSent

// ClientEventComplete indicates a deal has completed
// ClientEventComplete is fired when the provider sends a message
// indicating that a deal has completed
ClientEventComplete

// ClientEventDataTransferError emits when something go wrong at the data transfer level
Expand Down Expand Up @@ -123,6 +126,10 @@ const (
// ClientEventPaymentChannelSkip is fired when the total deal price is zero
// so there's no need to set up a payment channel
ClientEventPaymentChannelSkip

// ClientEventPaymentNotSent indicates that payment was requested, but no
// payment was actually due, so a voucher was not sent to the provider
ClientEventPaymentNotSent
)

// ClientEvents is a human readable map of client event name -> event description
Expand Down Expand Up @@ -163,6 +170,15 @@ var ClientEvents = map[ClientEvent]string{
ClientEventCancel: "ClientEventCancel",
ClientEventWaitForLastBlocks: "ClientEventWaitForLastBlocks",
ClientEventPaymentChannelSkip: "ClientEventPaymentChannelSkip",
ClientEventPaymentNotSent: "ClientEventPaymentNotSent",
}

func (e ClientEvent) String() string {
s, ok := ClientEvents[e]
if ok {
return s
}
return fmt.Sprintf("ClientEventUnknown: %d", e)
}

// ProviderEvent is an event that occurs in a deal lifecycle on the provider
Expand Down
89 changes: 66 additions & 23 deletions retrievalmarket/impl/clientstates/client_fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ var ClientEvents = fsm.Events{
rm.DealStatusOngoing,
rm.DealStatusFundsNeededLastPayment,
rm.DealStatusFundsNeeded).To(rm.DealStatusFundsNeededLastPayment).
From(rm.DealStatusSendFunds).To(rm.DealStatusOngoing).
From(rm.DealStatusCheckComplete).ToNoChange().
From(rm.DealStatusBlocksComplete).To(rm.DealStatusSendFundsLastPayment).
FromMany(
paymentChannelCreationStates...).ToJustRecord().
Expand All @@ -179,7 +181,10 @@ var ClientEvents = fsm.Events{
FromMany(
rm.DealStatusOngoing,
rm.DealStatusBlocksComplete,
rm.DealStatusFundsNeeded).To(rm.DealStatusFundsNeeded).
rm.DealStatusFundsNeeded,
rm.DealStatusFundsNeededLastPayment).To(rm.DealStatusFundsNeeded).
From(rm.DealStatusSendFunds).To(rm.DealStatusOngoing).
From(rm.DealStatusCheckComplete).ToNoChange().
FromMany(
paymentChannelCreationStates...).ToJustRecord().
Action(func(deal *rm.ClientDealState, paymentOwed abi.TokenAmount) error {
Expand All @@ -201,9 +206,11 @@ var ClientEvents = fsm.Events{
rm.DealStatusBlocksComplete,
).To(rm.DealStatusBlocksComplete).
FromMany(paymentChannelCreationStates...).ToJustRecord().
FromMany(rm.DealStatusSendFunds, rm.DealStatusFundsNeeded).ToJustRecord().
FromMany(rm.DealStatusSendFunds, rm.DealStatusSendFundsLastPayment).To(rm.DealStatusOngoing).
From(rm.DealStatusFundsNeeded).ToNoChange().
From(rm.DealStatusFundsNeededLastPayment).To(rm.DealStatusSendFundsLastPayment).
From(rm.DealStatusClientWaitingForLastBlocks).To(rm.DealStatusCompleted).
From(rm.DealStatusCheckComplete).To(rm.DealStatusCompleted).
Action(func(deal *rm.ClientDealState) error {
deal.AllBlocksReceived = true
return nil
Expand All @@ -214,10 +221,12 @@ var ClientEvents = fsm.Events{
rm.DealStatusFundsNeededLastPayment,
rm.DealStatusCheckComplete,
rm.DealStatusClientWaitingForLastBlocks).ToNoChange().
FromMany(rm.DealStatusSendFunds, rm.DealStatusSendFundsLastPayment).To(rm.DealStatusOngoing).
FromMany(paymentChannelCreationStates...).ToJustRecord().
Action(recordReceived),

fsm.Event(rm.ClientEventSendFunds).
FromMany(rm.DealStatusSendFunds, rm.DealStatusSendFundsLastPayment).To(rm.DealStatusOngoing).
From(rm.DealStatusFundsNeeded).To(rm.DealStatusSendFunds).
From(rm.DealStatusFundsNeededLastPayment).To(rm.DealStatusSendFundsLastPayment),

Expand Down Expand Up @@ -252,35 +261,68 @@ var ClientEvents = fsm.Events{
deal.Message = xerrors.Errorf("writing deal payment: %w", err).Error()
return nil
}),
fsm.Event(rm.ClientEventPaymentSent).

// Payment was requested, but there was not actually any payment due, so
// no payment voucher was actually sent
fsm.Event(rm.ClientEventPaymentNotSent).
From(rm.DealStatusOngoing).ToJustRecord().
From(rm.DealStatusSendFunds).To(rm.DealStatusOngoing).
From(rm.DealStatusSendFundsLastPayment).To(rm.DealStatusFinalizing),

fsm.Event(rm.ClientEventPaymentSent).
From(rm.DealStatusOngoing).ToJustRecord().
From(rm.DealStatusBlocksComplete).To(rm.DealStatusCheckComplete).
From(rm.DealStatusCheckComplete).ToNoChange().
FromMany(
rm.DealStatusFundsNeeded,
rm.DealStatusFundsNeededLastPayment,
rm.DealStatusSendFunds).To(rm.DealStatusOngoing).
From(rm.DealStatusSendFundsLastPayment).To(rm.DealStatusFinalizing).
Action(func(deal *rm.ClientDealState) error {
// paymentRequested = 0
// fundsSpent = fundsSpent + paymentRequested
// if paymentRequested / pricePerByte >= currentInterval
// currentInterval = currentInterval + proposal.intervalIncrease
// bytesPaidFor = bytesPaidFor + (paymentRequested / pricePerByte)
deal.FundsSpent = big.Add(deal.FundsSpent, deal.PaymentRequested)

paymentForUnsealing := big.Min(deal.PaymentRequested, big.Sub(deal.UnsealPrice, deal.UnsealFundsPaid))
deal.UnsealFundsPaid = big.Add(deal.UnsealFundsPaid, paymentForUnsealing)

// If the price per bytes is zero, we ONLY need to account for the Unsealing payments here.
if !deal.PricePerByte.IsZero() {
bytesPaidFor := big.Div(big.Sub(deal.PaymentRequested, paymentForUnsealing), deal.PricePerByte).Uint64()
if bytesPaidFor >= deal.CurrentInterval {
deal.CurrentInterval += deal.DealProposal.PaymentIntervalIncrease
}
deal.BytesPaidFor += bytesPaidFor
Action(func(deal *rm.ClientDealState, voucherAmt abi.TokenAmount) error {
// Reduce the payment requested by the amount of funds sent.
// Note that it may not be reduced to zero, if a new payment
// request came in while this one was being processed.
sentAmt := big.Sub(voucherAmt, deal.FundsSpent)
deal.PaymentRequested = big.Sub(deal.PaymentRequested, sentAmt)

// Update the total funds sent to the provider
deal.FundsSpent = voucherAmt

// If the unseal price hasn't yet been met, set the unseal funds
// paid to the amount sent to the provider
if deal.UnsealPrice.GreaterThanEqual(deal.FundsSpent) {
deal.UnsealFundsPaid = deal.FundsSpent
return nil
}
// The unseal funds have been fully paid
deal.UnsealFundsPaid = deal.UnsealPrice

// If the price per byte is zero, no further accounting needed
if deal.PricePerByte.IsZero() {
return nil
}

// Calculate the amount spent on transferring data, and update the
// bytes paid for accordingly
paidSoFarForTransfer := big.Sub(deal.FundsSpent, deal.UnsealFundsPaid)
deal.BytesPaidFor = big.Div(paidSoFarForTransfer, deal.PricePerByte).Uint64()

// If the number of bytes paid for is above the current interval,
// increase the interval
if deal.BytesPaidFor >= deal.CurrentInterval {
deal.CurrentInterval = deal.NextInterval()
}

deal.PaymentRequested = abi.NewTokenAmount(0)
return nil
}),

// completing deals
fsm.Event(rm.ClientEventComplete).
FromMany(
rm.DealStatusSendFunds,
rm.DealStatusSendFundsLastPayment,
rm.DealStatusFundsNeeded,
rm.DealStatusFundsNeededLastPayment).To(rm.DealStatusCheckComplete).
From(rm.DealStatusOngoing).To(rm.DealStatusCheckComplete).
From(rm.DealStatusBlocksComplete).To(rm.DealStatusCheckComplete).
From(rm.DealStatusFinalizing).To(rm.DealStatusCompleted),
Expand All @@ -297,7 +339,8 @@ var ClientEvents = fsm.Events{
// should wait for the last blocks to arrive (only needed when price
// per byte is zero)
fsm.Event(rm.ClientEventWaitForLastBlocks).
From(rm.DealStatusCheckComplete).To(rm.DealStatusClientWaitingForLastBlocks),
From(rm.DealStatusCheckComplete).To(rm.DealStatusClientWaitingForLastBlocks).
From(rm.DealStatusCompleted).ToJustRecord(),

// after cancelling a deal is complete
fsm.Event(rm.ClientEventCancelComplete).
Expand Down
Loading

0 comments on commit ad3d7d3

Please sign in to comment.