Skip to content

Commit 89f11ca

Browse files
Merge branch 'main' into fix/sessioninterestmanager
2 parents 37cb7ea + 5c158ec commit 89f11ca

File tree

121 files changed

+354
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+354
-421
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ The following emojis are used to highlight certain changes:
2525
### Security
2626

2727

28+
## [v0.27.3]
29+
30+
### Added
31+
32+
- `provider`: Added `ReprovideInterval` and `LastRun` stats to the Reprovider [#815](https://github.com/ipfs/boxo/pull/815)
33+
34+
2835
## [v0.27.2]
2936

3037
### Fixed

bitswap/bitswap.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ import (
99
"github.com/ipfs/boxo/bitswap/network"
1010
"github.com/ipfs/boxo/bitswap/server"
1111
"github.com/ipfs/boxo/bitswap/tracer"
12-
"github.com/ipfs/go-metrics-interface"
13-
1412
blockstore "github.com/ipfs/boxo/blockstore"
1513
exchange "github.com/ipfs/boxo/exchange"
1614
blocks "github.com/ipfs/go-block-format"
1715
"github.com/ipfs/go-cid"
1816
logging "github.com/ipfs/go-log/v2"
17+
"github.com/ipfs/go-metrics-interface"
1918
"github.com/libp2p/go-libp2p/core/peer"
2019
"github.com/libp2p/go-libp2p/core/routing"
21-
2220
"go.uber.org/multierr"
2321
)
2422

bitswap/client/internal/getter/getter.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import (
66

77
"github.com/ipfs/boxo/bitswap/client/internal"
88
notifications "github.com/ipfs/boxo/bitswap/client/internal/notifications"
9-
logging "github.com/ipfs/go-log/v2"
10-
119
blocks "github.com/ipfs/go-block-format"
1210
cid "github.com/ipfs/go-cid"
1311
ipld "github.com/ipfs/go-ipld-format"
12+
logging "github.com/ipfs/go-log/v2"
1413
)
1514

1615
var log = logging.Logger("bitswap/client/getter")

bitswap/client/internal/peermanager/peermanager.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import (
44
"context"
55
"sync"
66

7+
cid "github.com/ipfs/go-cid"
78
logging "github.com/ipfs/go-log/v2"
89
"github.com/ipfs/go-metrics-interface"
9-
10-
cid "github.com/ipfs/go-cid"
1110
peer "github.com/libp2p/go-libp2p/core/peer"
1211
)
1312

bitswap/client/internal/peermanager/peerwantmanager.go

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ func (pwm *peerWantManager) broadcastWantHaves(wantHaves []cid.Cid) {
158158
// sendWants only sends the peer the want-blocks and want-haves that have not
159159
// already been sent to it.
160160
func (pwm *peerWantManager) sendWants(p peer.ID, wantBlocks []cid.Cid, wantHaves []cid.Cid) {
161-
162161
// Get the existing want-blocks and want-haves for the peer
163162
pws, ok := pwm.peerWants[p]
164163
if !ok {
@@ -284,58 +283,51 @@ func (pwm *peerWantManager) sendCancels(cancelKs []cid.Cid) {
284283
}
285284
}
286285

287-
if len(broadcastCancels) > 0 {
288-
// If a broadcast want is being cancelled, send the cancel to all
289-
// peers
290-
for p, pws := range pwm.peerWants {
291-
send(p, pws)
292-
}
293-
} else {
294-
// Only send cancels to peers that received a corresponding want
295-
cancelPeers := make(map[peer.ID]struct{}, len(pwm.wantPeers[cancelKs[0]]))
296-
for _, c := range cancelKs {
297-
for p := range pwm.wantPeers[c] {
298-
cancelPeers[p] = struct{}{}
299-
}
300-
}
301-
for p := range cancelPeers {
302-
pws, ok := pwm.peerWants[p]
303-
if !ok {
304-
// Should never happen but check just in case
305-
log.Errorf("sendCancels - peerWantManager index missing peer %s", p)
306-
continue
307-
}
308-
309-
send(p, pws)
310-
}
311-
}
312-
313-
// Decrement the wants gauges
314-
for _, c := range cancelKs {
286+
clearWantsForCID := func(c cid.Cid) {
315287
peerCnts := peerCounts[c]
316-
317288
// If there were any peers that had a pending want-block for the key
318289
if peerCnts.wantBlock > 0 {
319290
// Decrement the want-block gauge
320291
pwm.wantBlockGauge.Dec()
321292
}
322-
323293
// If there was a peer that had a pending want or it was a broadcast want
324294
if peerCnts.wanted() {
325295
// Decrement the total wants gauge
326296
pwm.wantGauge.Dec()
327297
}
298+
delete(pwm.wantPeers, c)
328299
}
329300

330-
// Remove cancelled broadcast wants
331-
for _, c := range broadcastCancels {
332-
pwm.broadcastWants.Remove(c)
333-
}
301+
if len(broadcastCancels) > 0 {
302+
// If a broadcast want is being cancelled, send the cancel to all
303+
// peers
304+
for p, pws := range pwm.peerWants {
305+
send(p, pws)
306+
}
334307

335-
// Batch-remove the reverse-index. There's no need to clear this index
336-
// peer-by-peer.
337-
for _, c := range cancelKs {
338-
delete(pwm.wantPeers, c)
308+
// Remove cancelled broadcast wants
309+
for _, c := range broadcastCancels {
310+
pwm.broadcastWants.Remove(c)
311+
}
312+
313+
for _, c := range cancelKs {
314+
clearWantsForCID(c)
315+
}
316+
} else {
317+
// Only send cancels to peers that received a corresponding want
318+
for _, c := range cancelKs {
319+
for p := range pwm.wantPeers[c] {
320+
pws, ok := pwm.peerWants[p]
321+
if !ok {
322+
// Should never happen but check just in case
323+
log.Errorf("sendCancels - peerWantManager index missing peer %s", p)
324+
continue
325+
}
326+
send(p, pws)
327+
}
328+
329+
clearWantsForCID(c)
330+
}
339331
}
340332
}
341333

bitswap/client/internal/session/session_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ func (pm *fakePeerManager) UnregisterSession(uint64) {}
145145
func (pm *fakePeerManager) SendWants(context.Context, peer.ID, []cid.Cid, []cid.Cid) bool {
146146
return true
147147
}
148+
148149
func (pm *fakePeerManager) BroadcastWantHaves(ctx context.Context, cids []cid.Cid) {
149150
select {
150151
case pm.wantReqs <- wantReq{cids}:
@@ -287,7 +288,7 @@ func TestSessionFindMorePeers(t *testing.T) {
287288
// Make sure the first block is not included because it has already
288289
// been received
289290
for _, c := range receivedWantReq.cids {
290-
require.False(t, c.Equals(cids[0]), "should not braodcast block that was already received")
291+
require.False(t, c.Equals(cids[0]), "should not broadcast block that was already received")
291292
}
292293
case <-ctx.Done():
293294
t.Fatal("Never rebroadcast want list")

bitswap/client/internal/session/sessionwantsender.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
bsbpm "github.com/ipfs/boxo/bitswap/client/internal/blockpresencemanager"
7-
87
cid "github.com/ipfs/go-cid"
98
peer "github.com/libp2p/go-libp2p/core/peer"
109
)

bitswap/client/internal/sessioninterestmanager/sessioninterestmanager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"sync"
55

66
blocks "github.com/ipfs/go-block-format"
7-
87
cid "github.com/ipfs/go-cid"
98
)
109

bitswap/client/internal/sessionmanager/sessionmanager.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ import (
66
"sync"
77
"time"
88

9-
cid "github.com/ipfs/go-cid"
10-
delay "github.com/ipfs/go-ipfs-delay"
11-
"go.opentelemetry.io/otel/attribute"
12-
"go.opentelemetry.io/otel/trace"
13-
149
"github.com/ipfs/boxo/bitswap/client/internal"
1510
bsbpm "github.com/ipfs/boxo/bitswap/client/internal/blockpresencemanager"
1611
notifications "github.com/ipfs/boxo/bitswap/client/internal/notifications"
1712
bssession "github.com/ipfs/boxo/bitswap/client/internal/session"
1813
bssim "github.com/ipfs/boxo/bitswap/client/internal/sessioninterestmanager"
1914
exchange "github.com/ipfs/boxo/exchange"
15+
cid "github.com/ipfs/go-cid"
16+
delay "github.com/ipfs/go-ipfs-delay"
2017
peer "github.com/libp2p/go-libp2p/core/peer"
18+
"go.opentelemetry.io/otel/attribute"
19+
"go.opentelemetry.io/otel/trace"
2120
)
2221

2322
// Session is a session that is managed by the session manager

bitswap/client/internal/sessionpeermanager/sessionpeermanager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"sync"
66

77
logging "github.com/ipfs/go-log/v2"
8-
98
peer "github.com/libp2p/go-libp2p/core/peer"
109
)
1110

0 commit comments

Comments
 (0)