Skip to content

Commit 2690bfa

Browse files
committed
rebroadcast only when there are live CIDs
1 parent 66b389e commit 2690bfa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

bitswap/client/internal/session/session.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ func (s *Session) broadcast(ctx context.Context, wants []cid.Cid) {
375375
log.Debugw("FindMorePeers", "session", s.id, "cid", wants[0], "pending", len(wants))
376376
s.findMorePeers(ctx, wants[0])
377377
}
378-
s.resetIdleTick()
379378

380379
// If we have live wants record a consecutive tick
381380
if s.sw.HasLiveWants() {
381+
s.resetIdleTick()
382382
s.consecutiveTicks++
383383
}
384384
}
@@ -451,7 +451,10 @@ func (s *Session) handleReceive(ks []cid.Cid) {
451451
// that have occurred since the last new block
452452
s.consecutiveTicks = 0
453453

454-
s.resetIdleTick()
454+
// reset rebroadcast timer if we still have outstanding wants
455+
if s.sw.HasLiveWants() {
456+
s.resetIdleTick()
457+
}
455458
}
456459

457460
// wantBlocks is called when blocks are requested by the client

0 commit comments

Comments
 (0)