mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 12:11:36 +00:00
Manually clean peers on announce
This commit is contained in:
parent
5dcc932247
commit
7f98203d5e
@ -118,6 +118,11 @@ Swarm.prototype._getPeers = function (numwant, ownPeerId, isWebRTC) {
|
||||
var ite = randomIterate(Object.keys(this.peers.cache))
|
||||
var peerId
|
||||
while ((peerId = ite()) && peers.length < numwant) {
|
||||
// Check manually if the peer is active
|
||||
if (peers.maxAge && (Date.now() - peers.cache[peerId].modified) > peers.maxAge) {
|
||||
peers.remove(peerId)
|
||||
continue
|
||||
}
|
||||
// Don't mark the peer as most recently used on announce
|
||||
var peer = this.peers.peek(peerId)
|
||||
if (isWebRTC && peer.peerId === ownPeerId) continue // don't send peer to itself
|
||||
|
Loading…
Reference in New Issue
Block a user