Class UnchokerUtil

java.lang.Object
com.biglybt.core.peermanager.unchoker.UnchokerUtil

public class UnchokerUtil extends Object
Utility collection for unchokers.
  • Constructor Details

    • UnchokerUtil

      public UnchokerUtil()
  • Method Details

    • isUnchokable

      public static boolean isUnchokable(PEPeer peer, boolean allow_snubbed)
      Test whether or not the given peer is allowed to be unchoked.
      Parameters:
      peer - to test
      allow_snubbed - if true, ignore snubbed state
      Returns:
      true if peer is allowed to be unchoked, false if not
    • updateLargestValueFirstSort

      public static void updateLargestValueFirstSort(long new_value, long[] values, PEPeer new_item, ArrayList items, int start_pos)
      Update (if necessary) the given list with the given value while maintaining a largest-value-first (as seen so far) sort order. NOTE: You will need to initialize the values array to Long.MIN_VALUE if you want to store negative values!
      Parameters:
      new_value - to use
      values - existing values array
      new_item - to insert
      items - existing items
      start_pos - index at which to start compare
    • getNextOptimisticPeer

      public static PEPeer getNextOptimisticPeer(ArrayList<PEPeer> all_peers, boolean factor_reciprocated, boolean allow_snubbed)
      Choose the next peer, optimistically, that should be unchoked.
      Parameters:
      all_peers - list of peer to choose from
      factor_reciprocated - if true, factor in how much (if any) this peer has reciprocated when choosing
      allow_snubbed - allow the picking of snubbed-state peers as last resort
      Returns:
      the next peer to optimistically unchoke, or null if there are no peers available
    • getNextOptimisticPeers

      public static ArrayList<PEPeer> getNextOptimisticPeers(ArrayList<PEPeer> all_peers, boolean factor_reciprocated, boolean allow_snubbed, int num_needed)
    • performChokes

      public static void performChokes(ArrayList<PEPeer> peers_to_choke, ArrayList<PEPeer> peers_to_unchoke)
      Send choke/unchoke messages to the given peers.
      Parameters:
      peers_to_choke -
      peers_to_unchoke -
    • performChokeUnchoke

      public static void performChokeUnchoke(PEPeer to_choke, PEPeer to_unchoke)
    • doHighLatencyPeers

      public static void doHighLatencyPeers(ArrayList<PEPeer> peers_to_choke, ArrayList<PEPeer> peers_to_unchoke, boolean allow_snubbed)