Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit eb28a2e

Browse files
committed
feat(session): when periodically searching, broadcast want to connected peers
This fixes the case where: 1. I start downloading something. 2. A friend jumps on our WiFi. 3. Our IPFS daemons connect via local discovery. 4. I never notice that they have the file I'm looking for because I'm already downloading it from a peer. 5. The peer I'm downloading from is _really_ slow.
1 parent 2a00256 commit eb28a2e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

session/session.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,15 @@ func (s *Session) handleIdleTick(ctx context.Context) {
333333
}
334334

335335
func (s *Session) handlePeriodicSearch(ctx context.Context) {
336-
337-
if len(s.liveWants) == 0 {
336+
randomWant := s.randomLiveWant()
337+
if !randomWant.Defined() {
338338
return
339339
}
340340

341341
// TODO: come up with a better strategy for determining when to search
342342
// for new providers for blocks.
343-
s.pm.FindMorePeers(ctx, s.randomLiveWant())
343+
s.pm.FindMorePeers(ctx, randomWant)
344+
s.wm.WantBlocks(ctx, []cid.Cid{randomWant}, nil, s.id)
344345

345346
s.periodicSearchTimer.Reset(s.periodicSearchDelay.NextWaitTime())
346347
}

0 commit comments

Comments
 (0)