Class UnchokerUtil
- java.lang.Object
-
- com.biglybt.core.peermanager.unchoker.UnchokerUtil
-
public class UnchokerUtil extends java.lang.Object
Utility collection for unchokers.
-
-
Constructor Summary
Constructors Constructor Description UnchokerUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
doHighLatencyPeers(java.util.ArrayList<PEPeer> peers_to_choke, java.util.ArrayList<PEPeer> peers_to_unchoke, boolean allow_snubbed)
static PEPeer
getNextOptimisticPeer(java.util.ArrayList<PEPeer> all_peers, boolean factor_reciprocated, boolean allow_snubbed)
Choose the next peer, optimistically, that should be unchoked.static java.util.ArrayList<PEPeer>
getNextOptimisticPeers(java.util.ArrayList<PEPeer> all_peers, boolean factor_reciprocated, boolean allow_snubbed, int num_needed)
static boolean
isUnchokable(PEPeer peer, boolean allow_snubbed)
Test whether or not the given peer is allowed to be unchoked.static void
performChokes(java.util.ArrayList<PEPeer> peers_to_choke, java.util.ArrayList<PEPeer> peers_to_unchoke)
Send choke/unchoke messages to the given peers.static void
performChokeUnchoke(PEPeer to_choke, PEPeer to_unchoke)
static void
updateLargestValueFirstSort(long new_value, long[] values, PEPeer new_item, java.util.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.
-
-
-
Method Detail
-
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 testallow_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, java.util.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 usevalues
- existing values arraynew_item
- to insertitems
- existing itemsstart_pos
- index at which to start compare
-
getNextOptimisticPeer
public static PEPeer getNextOptimisticPeer(java.util.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 fromfactor_reciprocated
- if true, factor in how much (if any) this peer has reciprocated when choosingallow_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 java.util.ArrayList<PEPeer> getNextOptimisticPeers(java.util.ArrayList<PEPeer> all_peers, boolean factor_reciprocated, boolean allow_snubbed, int num_needed)
-
performChokes
public static void performChokes(java.util.ArrayList<PEPeer> peers_to_choke, java.util.ArrayList<PEPeer> peers_to_unchoke)
Send choke/unchoke messages to the given peers.- Parameters:
peers_to_choke
-peers_to_unchoke
-
-
-