Class UnchokerUtil
java.lang.Object
com.biglybt.core.peermanager.unchoker.UnchokerUtil
Utility collection for unchokers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddoHighLatencyPeers(ArrayList<PEPeer> peers_to_choke, ArrayList<PEPeer> peers_to_unchoke, boolean allow_snubbed) static PEPeergetNextOptimisticPeer(ArrayList<PEPeer> all_peers, boolean factor_reciprocated, boolean allow_snubbed) Choose the next peer, optimistically, that should be unchoked.getNextOptimisticPeers(ArrayList<PEPeer> all_peers, boolean factor_reciprocated, boolean allow_snubbed, int num_needed) static booleanisUnchokable(PEPeer peer, boolean allow_snubbed) Test whether or not the given peer is allowed to be unchoked.static voidperformChokes(ArrayList<PEPeer> peers_to_choke, ArrayList<PEPeer> peers_to_unchoke) Send choke/unchoke messages to the given peers.static voidperformChokeUnchoke(PEPeer to_choke, PEPeer to_unchoke) static voidupdateLargestValueFirstSort(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.
-
Constructor Details
-
UnchokerUtil
public UnchokerUtil()
-
-
Method Details
-
isUnchokable
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, 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(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
-
performChokes
-
performChokeUnchoke
-
doHighLatencyPeers
-