fix: idiomatic go
1. No need to slice a slice. 2. Idiomatic filter (https://github.com/golang/go/wiki/SliceTricks).
This commit is contained in:
parent
263a85c2a6
commit
16f8a35e76
@ -257,7 +257,7 @@ func (p *DealPublisher) publishAllDeals() {
|
|||||||
|
|
||||||
// Filter out any deals that have been cancelled
|
// Filter out any deals that have been cancelled
|
||||||
p.filterCancelledDeals()
|
p.filterCancelledDeals()
|
||||||
deals := p.pending[:]
|
deals := p.pending
|
||||||
p.pending = nil
|
p.pending = nil
|
||||||
|
|
||||||
// Send the publish message
|
// Send the publish message
|
||||||
@ -384,12 +384,12 @@ func pieceCids(deals []market2.ClientDealProposal) string {
|
|||||||
|
|
||||||
// filter out deals that have been cancelled
|
// filter out deals that have been cancelled
|
||||||
func (p *DealPublisher) filterCancelledDeals() {
|
func (p *DealPublisher) filterCancelledDeals() {
|
||||||
i := 0
|
filtered := p.pending[:0]
|
||||||
for _, pd := range p.pending {
|
for _, pd := range p.pending {
|
||||||
if pd.ctx.Err() == nil {
|
if pd.ctx.Err() != nil {
|
||||||
p.pending[i] = pd
|
continue
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
|
filtered = append(filtered, pd)
|
||||||
}
|
}
|
||||||
p.pending = p.pending[:i]
|
p.pending = filtered
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user