public class PeerID extends Object implements Comparable<PeerID>
| Constructor and Description |
|---|
PeerID(BDecoder be)Creates a PeerID from a BDecoder. |
PeerID(byte[] id,
Destination address)Creates a PeerID from a peer ID byte array and destination address. |
PeerID(byte[] dest_hash,
I2PSnarkUtil util)Creates a PeerID from a destHash |
PeerID(Map<String,BEValue> m)Creates a PeerID from a Map containing BEncoded peer id, ip and port. |
| Modifier and Type | Method and Description |
|---|---|
int | compareTo(PeerID pid)Compares port, address and id. |
boolean | equals(Object o)Two PeerIDs are equal when they have the same dest hash |
Destination | getAddress()Get the destination. |
byte[] | getDestHash() |
byte[] | getID()Returns the peer ID bytes. |
int | getPort()Returns the port number. |
int | hashCode()The hash code of a PeerID is the hashcode of the desthash |
static String | idencode(byte[] bs)Encode an id as a hex encoded string and remove leading zeros. |
boolean | sameID(PeerID pid)Returns true if and only if this peerID and the given peerID have the same destination hash |
void | setID(byte[] xid)for connecting out to peer based on desthash @since 0.8.1 |
String | toString()Returns the String "id@address" where id is the first 4 chars of the base64 encoded id and
address is the first 6 chars of the base64 dest (was the base64 hash of the dest) which
should match what the bytemonsoon tracker reports on its web pages. |
public PeerID(BDecoder be) throws IOException
be - the BDecoder to read fromIOException - if the bencoded data is invalidpublic PeerID(byte[] id,
Destination address)id - the peer ID bytesaddress - the destination addresspublic PeerID(byte[] dest_hash,
I2PSnarkUtil util)
throws InvalidBEncodingExceptionutil - for eventual destination lookupInvalidBEncodingExceptionpublic PeerID(Map<String,BEValue> m) throws InvalidBEncodingException
m - the map containing peer id and ip entriesInvalidBEncodingException - if the map entries are missing or invalidpublic int compareTo(PeerID pid)
compareTo in interface Comparable<PeerID>pid - the peer ID to compare topublic boolean equals(Object o)
public Destination getAddress()
public byte[] getDestHash()
public byte[] getID()
public int getPort()
public int hashCode()
public static String idencode(byte[] bs)
public boolean sameID(PeerID pid)
public void setID(byte[] xid)
public String toString()