def selectOptimisticPeer(classifiedPeers)
      # "at any one time there is a single peer which is unchoked regardless of its upload rate (if interested, it counts as one of the four allowed downloaders). Which peer is optimistically 
      # unchoked rotates every 30 seconds. Newly connected peers are three times as likely to start as the current optimistic unchoke as anywhere else in the rotation. This gives them a decent chance 
      # of getting a complete piece to upload."

      if !@lastOptimisticPeerChangeTime || (Time.new - @lastOptimisticPeerChangeTime > @optimisticPeerChangeDuration)
        list = []
        classifiedPeers.establishedPeers.each do |peer| 
          if (Time.new - peer.firstEstablishTime) < @newlyConnectedDuration
            3.times{ list.push peer }
          else
            list.push peer
          end
        end
        @optimisticUnchokePeer = list[rand(list.size)]
        if @optimisticUnchokePeer
          @logger.info "Optimistically unchoked peer set to #{@optimisticUnchokePeer.trackerPeer}"
          @lastOptimisticPeerChangeTime = Time.new
        end
      end
    end
def selectOptimisticPeer(classifiedPeers)
      # "at any one time there is a single peer which is unchoked regardless of its upload rate (if interested, it counts as one of the four allowed downloaders). Which peer is optimistically 
      # unchoked rotates every 30 seconds. Newly connected peers are three times as likely to start as the current optimistic unchoke as anywhere else in the rotation. This gives them a decent chance 
      # of getting a complete piece to upload."

      if !@lastOptimisticPeerChangeTime || (Time.new - @lastOptimisticPeerChangeTime > @optimisticPeerChangeDuration)
        list = []
        classifiedPeers.establishedPeers.each do |peer| 
          if (Time.new - peer.firstEstablishTime) < @newlyConnectedDuration
            3.times{ list.push peer }
          else
            list.push peer
          end
        end
        @optimisticUnchokePeer = list[rand(list.size)]
        if @optimisticUnchokePeer
          @logger.info "Optimistically unchoked peer set to #{@optimisticUnchokePeer.trackerPeer}"
          @lastOptimisticPeerChangeTime = Time.new
        end
      end
    end
Choose a peer that we will optimistically unchoke.