Class PeerIdentityManager


  • public class PeerIdentityManager
    extends java.lang.Object
    Maintains peer identity information.
    • Constructor Detail

      • PeerIdentityManager

        public PeerIdentityManager()
    • Method Detail

      • 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 connection
        peer_id - unique id for this peer connection
        ip - 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 connection
        peer_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 connection
        peer_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 connection
        ip - IP address to check for
        Returns:
        true if the IP is found, false if not found