From 72f58b1de168313a5c91e08cb023f2ac6a8f7e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 11 Nov 2022 17:39:04 +0100 Subject: [PATCH] feat: Drop active retrieval check (#764) --- retrievalmarket/impl/client.go | 35 +--------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/retrievalmarket/impl/client.go b/retrievalmarket/impl/client.go index 06c6ef96..c9a623af 100644 --- a/retrievalmarket/impl/client.go +++ b/retrievalmarket/impl/client.go @@ -3,7 +3,6 @@ package retrievalimpl import ( "context" "errors" - "fmt" "sync" "github.com/hannahhoward/go-pubsub" @@ -256,14 +255,7 @@ func (c *Client) Retrieve( c.retrieveLk.Lock() defer c.retrieveLk.Unlock() - // Check if there's already an active retrieval deal with the same peer - // for the same payload CID - err := c.checkForActiveDeal(payloadCID, p.ID) - if err != nil { - return 0, err - } - - err = c.addMultiaddrs(ctx, p) + err := c.addMultiaddrs(ctx, p) if err != nil { return 0, err } @@ -307,31 +299,6 @@ func (c *Client) Retrieve( return id, nil } -// Check if there's already an active retrieval deal with the same peer -// for the same payload CID -func (c *Client) checkForActiveDeal(payloadCID cid.Cid, pid peer.ID) error { - var deals []retrievalmarket.ClientDealState - err := c.stateMachines.List(&deals) - if err != nil { - return err - } - - for _, deal := range deals { - match := deal.Sender == pid && deal.PayloadCID == payloadCID - active := !clientstates.IsFinalityState(deal.Status) - if match && active { - msg := fmt.Sprintf("there is an active retrieval deal with peer %s ", pid) - msg += fmt.Sprintf("for payload CID %s ", payloadCID) - msg += fmt.Sprintf("(retrieval deal ID %d, state %s) - ", - deal.ID, retrievalmarket.DealStatuses[deal.Status]) - msg += "existing deal must be cancelled before starting a new retrieval deal" - err := xerrors.Errorf(msg) - return err - } - } - return nil -} - func (c *Client) notifySubscribers(eventName fsm.EventName, state fsm.StateType) { evt := eventName.(retrievalmarket.ClientEvent) ds := state.(retrievalmarket.ClientDealState)