Skip to content

Commit

Permalink
fix: use contiune instead of return
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Mar 30, 2023
1 parent a7fd163 commit d8d892d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion retrievalprovider/requestvalidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (rv *ProviderRequestValidator) acceptDeal(ctx context.Context, deal *types.
for _, minerDeal := range minerDeals {
minerCfg, err := rv.cfg.MinerProviderConfig(minerDeal.Proposal.Provider, true)
if err != nil {
return retrievalmarket.DealStatusErrored, err
continue
}
if minerCfg.RetrievalPaymentAddress.Unwrap().Empty() {
continue
Expand Down
16 changes: 10 additions & 6 deletions retrievalprovider/stream_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ func (p *RetrievalStreamHandler) HandleQueryStream(stream rmnet.RetrievalQuerySt

minerCfg, err := p.cfg.MinerProviderConfig(deal.Proposal.Provider, true)
if err != nil {
answer.Status = retrievalmarket.QueryResponseError
answer.Message = err.Error()
sendResp(answer)
answers[i].Status = retrievalmarket.QueryResponseError
answers[i].Message = err.Error()
continue
}
paymentAddr := minerCfg.RetrievalPaymentAddress.Unwrap()
if paymentAddr == address.Undef {
Expand All @@ -120,15 +120,19 @@ func (p *RetrievalStreamHandler) HandleQueryStream(stream rmnet.RetrievalQuerySt
return
}

var firstErrorIdx = -1
validAnswers := make([]*retrievalmarket.QueryResponse, 0, validDealCount)
for i, deal := range minerDeals {
if len(answers[i].Message) != 0 {
continue
}
ask, err := p.askRepo.GetAsk(ctx, deal.Proposal.Provider)
if err != nil {
answer.Status = retrievalmarket.QueryResponseError
answer.Message = fmt.Sprintf("failed to got deal price: %s, %s", deal.Proposal.Provider, err)
if firstErrorIdx == -1 {
firstErrorIdx = i
}
answers[i].Status = retrievalmarket.QueryResponseError
answers[i].Message = fmt.Sprintf("failed to got deal price: %s, %s", deal.Proposal.Provider, err)
continue
}

Expand All @@ -140,7 +144,7 @@ func (p *RetrievalStreamHandler) HandleQueryStream(stream rmnet.RetrievalQuerySt
}

if len(validAnswers) == 0 {
sendResp(answers[0])
sendResp(answers[firstErrorIdx])
} else {
sendResp(*validAnswers[0])
}
Expand Down

0 comments on commit d8d892d

Please sign in to comment.