Small fixes base on comments in PR #261
This commit is contained in:
parent
42d184ff6b
commit
90a823b3ed
1 changed files with 12 additions and 6 deletions
|
|
@ -884,7 +884,7 @@ impl TorrentStateLive {
|
|||
None
|
||||
}
|
||||
})
|
||||
.take(50)
|
||||
.take(MAX_SENT_PEERS)
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
let addrs_closed_to_sent = sent_peers_live
|
||||
|
|
@ -905,16 +905,23 @@ impl TorrentStateLive {
|
|||
// and addrs_closed_to_sent are only filtered addresses from sent_peers_live
|
||||
|
||||
if !addrs_live_to_sent.is_empty() || !addrs_closed_to_sent.is_empty() {
|
||||
debug!("sending PEX with {} live ({:?})and {} closed peers", addrs_live_to_sent.len(), addrs_live_to_sent,addrs_closed_to_sent.len());
|
||||
debug!(
|
||||
"sending PEX with {} live ({:?})and {} closed peers",
|
||||
addrs_live_to_sent.len(),
|
||||
addrs_live_to_sent,
|
||||
addrs_closed_to_sent.len()
|
||||
);
|
||||
let pex_msg =
|
||||
extended::ut_pex::UtPex::from_addrs(&addrs_live_to_sent, &addrs_closed_to_sent);
|
||||
let ext_msg = extended::ExtendedMessage::UtPex(pex_msg);
|
||||
let msg = Message::Extended(ext_msg);
|
||||
|
||||
if tx.send(WriterRequest::Message(msg)).is_ok() {
|
||||
sent_peers_live.extend(&addrs_live_to_sent);
|
||||
sent_peers_live.retain(|addr| !addrs_closed_to_sent.contains(addr));
|
||||
if tx.send(WriterRequest::Message(msg)).is_err() {
|
||||
return Ok(()); // Peer disconnected
|
||||
}
|
||||
|
||||
sent_peers_live.extend(&addrs_live_to_sent);
|
||||
sent_peers_live.retain(|addr| !addrs_closed_to_sent.contains(addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1859,7 +1866,6 @@ impl PeerHandler {
|
|||
B: AsRef<[u8]> + std::fmt::Debug,
|
||||
{
|
||||
// TODO: this is just first attempt at pex - will need more sophistication on adding peers - BEP 40, check number of live, seen peers ...
|
||||
debug!("received PEX message with {} added peers and {} dropped peers", msg.added_peers().count(), msg.dropped_peers().count());
|
||||
msg.dropped_peers()
|
||||
.chain(msg.added_peers())
|
||||
.for_each(|peer| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue