Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #477 from ipfs-force-community/fix/clean-blockstore #478

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions cli/retrieval-deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,12 @@ part statuses:
}

_, _ = fmt.Fprintf(w,
"%s\t%d\t%s\t%s\t%s\t%d\t%d\t%d\t%s\n",
"%s\t%d\t%s\t%s\t%s\t%d\t%d\t%s\n",
deal.Receiver.String(),
deal.ID,
payloadCid,
retrievalmarket.DealStatuses[deal.Status],
deal.PricePerByte.String(),
deal.TotalSent,
deal.FundsReceived,
deal.CurrentInterval,
deal.Message,
Expand Down Expand Up @@ -192,7 +191,6 @@ func outputRetrievalDeal(deal *market.ProviderDealState) error {
{"PayloadCID", deal.PayloadCID},
{"Status", retrievalmarket.DealStatuses[deal.Status]},
{"PricePerByte", deal.PricePerByte.String()},
{"BytesSent", deal.TotalSent},
{"Paid", deal.FundsReceived},
{"Interval", deal.CurrentInterval},
{"Message", deal.Message},
Expand Down
23 changes: 16 additions & 7 deletions retrievalprovider/provider_datatransfer_sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func ProviderDataTransferSubscriber(deals IDatatransferHandler) datatransfer.Sub
dealProposal, err := rm.DealProposalFromNode(voucher.Voucher)
// if this event is for a transfer not related to storage, ignore
if err != nil {
log.Errorf("received wrong voucher type: %s", err)
return
}

Expand All @@ -40,26 +41,26 @@ func ProviderDataTransferSubscriber(deals IDatatransferHandler) datatransfer.Sub

switch event.Code {
case datatransfer.Accept:
mlog.With("retrievalEvent", rm.ProviderEventDealAccepted)
mlog = mlog.With("retrievalEvent", rm.ProviderEvents[rm.ProviderEventDealAccepted])
err := deals.HandleAcceptFor(ctx, identify, channelState.ChannelID())
if err != nil {
log.Errorf("processing dt event: %s", err)
}
case datatransfer.Disconnected:
mlog.With("retrievalEvent", rm.ProviderEventDataTransferError)
mlog = mlog.With("retrievalEvent", rm.ProviderEvents[rm.ProviderEventDataTransferError])
err := deals.HandleDisconnectFor(ctx, identify, fmt.Errorf("deal data transfer stalled (peer hungup)"))
if err != nil {
log.Errorf("processing dt event: %s", err)
}
case datatransfer.Error:
mlog.With("retrievalEvent", rm.ProviderEventDataTransferError)
mlog = mlog.With("retrievalEvent", rm.ProviderEvents[rm.ProviderEventDataTransferError])
err := deals.HandleErrorForDeal(ctx, identify, fmt.Errorf("deal data transfer failed: %s", event.Message))
if err != nil {
log.Errorf("processing dt event: %s", err)
}
case datatransfer.DataLimitExceeded:
// DataLimitExceeded indicates it's time to wait for a payment
mlog.With("retrievalEvent", rm.ProviderEventPaymentRequested)
mlog = mlog.With("retrievalEvent", rm.ProviderEvents[rm.ProviderEventPaymentRequested])
err := deals.HandlePaymentRequested(ctx, identify)
if err != nil {
log.Errorf("processing dt event: %s", err)
Expand All @@ -69,24 +70,32 @@ func ProviderDataTransferSubscriber(deals IDatatransferHandler) datatransfer.Sub
// Because the legacy client expects a final voucher, we dispatch this event event when
// the deal is free -- so that we have a chance to send this final voucher before completion
// TODO: do not send the legacy voucher when the client no longer expects it
mlog.With("retrievalEvent", rm.ProviderEventLastPaymentRequested)
mlog = mlog.With("retrievalEvent", rm.ProviderEvents[rm.ProviderEventLastPaymentRequested])
err := deals.HandleLastPayment(ctx, identify)
if err != nil {
log.Errorf("processing dt event: %s", err)
}
case datatransfer.NewVoucher:
// NewVoucher indicates a potential new payment we should attempt to process
mlog.With("retrievalEvent", rm.ProviderEventProcessPayment)
mlog = mlog.With("retrievalEvent", rm.ProviderEvents[rm.ProviderEventProcessPayment])
err := deals.HandleProcessPayment(ctx, identify)
if err != nil {
log.Errorf("processing dt event: %s", err)
}
case datatransfer.Cancel:
mlog.With("retrievalEvent", rm.ProviderEventClientCancelled)
mlog = mlog.With("retrievalEvent", rm.ProviderEvents[rm.ProviderEventClientCancelled])
err := deals.HandleCancelForDeal(ctx, identify)
if err != nil {
log.Errorf("processing dt event: %s", err)
}
case datatransfer.NewVoucherResult:
mlog = mlog.With("channelStatus", channelState.Status())
if channelState.Status() == datatransfer.Finalizing {
err := deals.HandleCompleteFor(ctx, identify)
if err != nil {
log.Errorf("processing dt event: %s", err)
}
}
default:
return
}
Expand Down