feat: dealpublisher: check for duplicate deals before adding
This commit is contained in:
parent
4aa532390c
commit
54a4f14d09
@ -204,6 +204,26 @@ func (p *DealPublisher) processNewDeal(pdeal *pendingDeal) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdealPropCid, err := pdeal.deal.Proposal.Cid()
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("failed to calculate proposal CID for new pending Deal with piece cid %s", pdeal.deal.Proposal.PieceCID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanity check that new deal isn't already in the queue
|
||||||
|
for _, pd := range p.pending {
|
||||||
|
pdPropCid, err := pd.deal.Proposal.Cid()
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("failed to calculate proposal CID for pending Deal already in publish queue with piece cid %s", pd.deal.Proposal.PieceCID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if pdPropCid.Equals(pdealPropCid) {
|
||||||
|
log.Warn("tried to process new pending deal with piece CID %s that is already in publish queue; returning", pdeal.deal.Proposal.PieceCID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add the new deal to the queue
|
// Add the new deal to the queue
|
||||||
p.pending = append(p.pending, pdeal)
|
p.pending = append(p.pending, pdeal)
|
||||||
log.Infof("add deal with piece CID %s to publish deals queue - %d deals in queue (max queue size %d)",
|
log.Infof("add deal with piece CID %s to publish deals queue - %d deals in queue (max queue size %d)",
|
||||||
|
Loading…
Reference in New Issue
Block a user