Package com.biglybt.core.peer.util
Class PeerIdentityManager
- java.lang.Object
-
- com.biglybt.core.peer.util.PeerIdentityManager
-
public class PeerIdentityManager extends java.lang.Object
Maintains peer identity information.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PeerIdentityManager.DataEntry
private static class
PeerIdentityManager.PeerIdentity
-
Field Summary
Fields Modifier and Type Field Description private static AEMonitor
class_mon
private static java.util.Map<PeerIdentityDataID,PeerIdentityManager.DataEntry>
dataMap
private static boolean
MUTLI_CONTROLLERS
private static int
totalIDs
-
Constructor Summary
Constructors Constructor Description PeerIdentityManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
addIdentity(PeerIdentityDataID data_id, byte[] peer_id, int local_port, java.lang.String ip)
Add a new peer identity to the manager.static boolean
containsIdentity(PeerIdentityDataID data_id, byte[] peer_id, int local_port)
Check if the manager already has the given peer identity.static boolean
containsIPAddress(PeerIdentityDataID data_id, java.lang.String ip)
Check if the given IP address is already present in the manager's peer identity list for the given data item (i.e.static PeerIdentityDataID
createDataID(byte[] data)
static int
getIdentityCount(PeerIdentityDataID data_id)
Get the total number of peer identities managed for the given data item.static int
getTotalIdentityCount()
Get the total number of peer identities managed.static void
removeIdentity(PeerIdentityDataID data_id, byte[] peer_id, int local_port)
Remove a peer identity from the manager.
-
-
-
Field Detail
-
MUTLI_CONTROLLERS
private static final boolean MUTLI_CONTROLLERS
-
class_mon
private static final AEMonitor class_mon
-
dataMap
private static final java.util.Map<PeerIdentityDataID,PeerIdentityManager.DataEntry> dataMap
-
totalIDs
private static int totalIDs
-
-
Method Detail
-
createDataID
public static PeerIdentityDataID createDataID(byte[] data)
-
addIdentity
public static boolean addIdentity(PeerIdentityDataID data_id, byte[] peer_id, int local_port, java.lang.String ip)
Add a new peer identity to the manager.- Parameters:
data_id
- unique id for the data item associated with this connectionpeer_id
- unique id for this peer connectionip
- remote peer's ip address
-
removeIdentity
public static void removeIdentity(PeerIdentityDataID data_id, byte[] peer_id, int local_port)
Remove a peer identity from the manager.- Parameters:
data_id
- id for the data item associated with this connectionpeer_id
- id for this peer connection
-
containsIdentity
public static boolean containsIdentity(PeerIdentityDataID data_id, byte[] peer_id, int local_port)
Check if the manager already has the given peer identity.- Parameters:
data_id
- id for the data item associated with this connectionpeer_id
- id for this peer connection- Returns:
- true if the peer identity is found, false if not found
-
getTotalIdentityCount
public static int getTotalIdentityCount()
Get the total number of peer identities managed.- Returns:
- total number of peers over all data items
-
getIdentityCount
public static int getIdentityCount(PeerIdentityDataID data_id)
Get the total number of peer identities managed for the given data item.- Parameters:
data_id
- data item to count over- Returns:
- total number of peers for this data item
-
containsIPAddress
public static boolean containsIPAddress(PeerIdentityDataID data_id, java.lang.String ip)
Check if the given IP address is already present in the manager's peer identity list for the given data item (i.e. check if there is already a peer with that IP address).- Parameters:
data_id
- id for the data item associated with this connectionip
- IP address to check for- Returns:
- true if the IP is found, false if not found
-
-