For a while I was observing how dead peers are retried and found couple of thing, which I think are sub-optimal:
when incoming peer has error, then on_peer_died is called and eventually peer is scheduled as outgoing, The SocketAddress in this case has outgoing port of peer I think, so retry with it as outgoing does not make sense to me.
scheduled retries stay pending even after the download of torrent is finished ( often with long waiting times). They keep popping out long after then. I think it would be better to cancel them after download finishes.
This not final PR - rather a sketch to illustrate my findings. There is probably better way to solve it.
If you don't mind, I'll play more around this PR - remove first cancellation as it it clearly wrong now and look only on preventing retry on failed incoming peers.
For a while I was observing how dead peers are retried and found couple of thing, which I think are sub-optimal:
on_peer_died
is called and eventually peer is scheduled as outgoing, TheSocketAddress
in this case has outgoing port of peer I think, so retry with it as outgoing does not make sense to me.This not final PR - rather a sketch to illustrate my findings. There is probably better way to solve it.