def getPeersFromTracker(torrentData, infoHash)
      addPeer = Proc.new do |trackerPeer|
        peer = Peer.new(trackerPeer)
        peer.infoHash = infoHash
        torrentData.peers.add peer
        true
      end

      classifiedPeers = nil
      replaceDisconnectedPeer = Proc.new do |trackerPeer|
        classifiedPeers = ClassifiedPeers.new(torrentData.peers.all) if ! classifiedPeers
  
        if classifiedPeers.disconnectedPeers.size > 0
          torrentData.peers.delete classifiedPeers.disconnectedPeers.pop
          addPeer.call trackerPeer
          true
        else
          false
        end
      end

      trackerclient = torrentData.trackerClient 
    
      addProc = addPeer
      flipped = false
      trackerclient.peers.each do |p|
        if ! flipped && torrentData.peers.size >= @maxPeerCount
          addProc = replaceDisconnectedPeer
          flipped = true
        end
      
        # Don't treat ourself as a peer.
        next if p.id && p.id == trackerclient.peerId
            
        if ! torrentData.peers.findByAddr(p.ip, p.port)
          @logger.debug "#{QuartzTorrent.bytesToHex(torrentData.infoHash)}: Adding tracker peer #{p} to peers list"
          break if ! addProc.call(p)
        end
      end
    end
def getPeersFromTracker(torrentData, infoHash)
      addPeer = Proc.new do |trackerPeer|
        peer = Peer.new(trackerPeer)
        peer.infoHash = infoHash
        torrentData.peers.add peer
        true
      end

      classifiedPeers = nil
      replaceDisconnectedPeer = Proc.new do |trackerPeer|
        classifiedPeers = ClassifiedPeers.new(torrentData.peers.all) if ! classifiedPeers
  
        if classifiedPeers.disconnectedPeers.size > 0
          torrentData.peers.delete classifiedPeers.disconnectedPeers.pop
          addPeer.call trackerPeer
          true
        else
          false
        end
      end

      trackerclient = torrentData.trackerClient 
    
      addProc = addPeer
      flipped = false
      trackerclient.peers.each do |p|
        if ! flipped && torrentData.peers.size >= @maxPeerCount
          addProc = replaceDisconnectedPeer
          flipped = true
        end
      
        # Don't treat ourself as a peer.
        next if p.id && p.id == trackerclient.peerId
            
        if ! torrentData.peers.findByAddr(p.ip, p.port)
          @logger.debug "#{QuartzTorrent.bytesToHex(torrentData.infoHash)}: Adding tracker peer #{p} to peers list"
          break if ! addProc.call(p)
        end
      end
    end
def getPeersFromTracker ( torrentData , infoHash ) addPeer = Proc . new do | trackerPeer | peer = Peer . new ( trackerPeer ) peer . infoHash = infoHash torrentData . peers . add peer true end classifiedPeers = nil replaceDisconnectedPeer = Proc . new do | trackerPeer | classifiedPeers = ClassifiedPeers . new ( torrentData . peers . all ) if ! classifiedPeers if classifiedPeers . disconnectedPeers . size > 0 torrentData . peers . delete classifiedPeers . disconnectedPeers . pop addPeer . call trackerPeer true else false end end trackerclient = torrentData . trackerClient addProc = addPeer flipped = false trackerclient . peers . each do | p | if ! flipped && torrentData . peers . size >= @maxPeerCount addProc = replaceDisconnectedPeer flipped = true end # Don't treat ourself as a peer. next if p . id && p . id == trackerclient . peerId if ! torrentData . peers . findByAddr ( p . ip , p . port ) @logger . debug "#{QuartzTorrent.bytesToHex(torrentData.infoHash)}: Adding tracker peer #{p} to peers list" break if ! addProc . call ( p ) end end end
Update our internal peer list for this torrent from the tracker client
Update our internal peer list for this torrent from the tracker client