mirror of
https://github.com/logos-storage/bittorrent-tracker.git
synced 2026-01-05 22:43:08 +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 ite = randomIterate(Object.keys(this.peers.cache))
|
||||||
var peerId
|
var peerId
|
||||||
while ((peerId = ite()) && peers.length < numwant) {
|
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
|
// Don't mark the peer as most recently used on announce
|
||||||
var peer = this.peers.peek(peerId)
|
var peer = this.peers.peek(peerId)
|
||||||
if (isWebRTC && peer.peerId === ownPeerId) continue // don't send peer to itself
|
if (isWebRTC && peer.peerId === ownPeerId) continue // don't send peer to itself
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user