Commit eb28a2e1 authored by Steven Allen's avatar Steven Allen

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.
parent 2a00256b
......@@ -333,14 +333,15 @@ func (s *Session) handleIdleTick(ctx context.Context) {
}
func (s *Session) handlePeriodicSearch(ctx context.Context) {
if len(s.liveWants) == 0 {
randomWant := s.randomLiveWant()
if !randomWant.Defined() {
return
}
// TODO: come up with a better strategy for determining when to search
// for new providers for blocks.
s.pm.FindMorePeers(ctx, s.randomLiveWant())
s.pm.FindMorePeers(ctx, randomWant)
s.wm.WantBlocks(ctx, []cid.Cid{randomWant}, nil, s.id)
s.periodicSearchTimer.Reset(s.periodicSearchDelay.NextWaitTime())
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment