|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.data.DataStructureImpl
net.i2p.data.SimpleDataStructure
org.klomp.snark.dht.NodeInfo
class NodeInfo
Field Summary | |
---|---|
static int |
LENGTH
|
Fields inherited from class net.i2p.data.SimpleDataStructure |
---|
_data |
Constructor Summary | |
---|---|
NodeInfo(byte[] compactInfo,
int offset)
No Destination yet available |
|
NodeInfo(Destination dest,
int port)
With a fake NID used for pings |
|
NodeInfo(NID nID,
Destination dest,
int port)
Use this if we have the full destination |
|
NodeInfo(NID nID,
Hash hash,
int port)
No Destination yet available |
|
NodeInfo(String s)
Create from persistent storage string. |
Method Summary | |
---|---|
Hash |
calculateHash()
Calculate the SHA256 value of this object (useful for a few scenarios) |
boolean |
equals(Object o)
Warning - this returns true for two different classes with the same size and same data, e.g. |
static NID |
generateNID(Hash h,
int p,
RandomSource random)
Generate a secure NID that matches the Hash and port. |
Destination |
getDestination()
|
Hash |
getHash()
|
NID |
getNID()
|
int |
getPort()
|
int |
hashCode()
We assume the data has enough randomness in it, so use the first 4 bytes for speed. |
long |
lastSeen()
|
int |
length()
The legal length of the byte array in this data structure |
void |
setDestination(Destination dest)
This can come in later but the hash must match. |
String |
toPersistentString()
To persistent storage string. |
String |
toString()
|
Methods inherited from class net.i2p.data.SimpleDataStructure |
---|
fromBase64, fromByteArray, getData, readBytes, setData, toBase64, toByteArray, writeBytes |
Methods inherited from class net.i2p.data.DataStructureImpl |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int LENGTH
Constructor Detail |
---|
public NodeInfo(Destination dest, int port)
public NodeInfo(NID nID, Destination dest, int port)
IllegalArgumentException
public NodeInfo(NID nID, Hash hash, int port)
IllegalArgumentException
public NodeInfo(byte[] compactInfo, int offset)
compactInfo
- 20 byte node ID, 32 byte destHash, 2 byte portoffset
- starting at this offset in compactInfo
IllegalArgumentException
AIOOBE
public NodeInfo(String s) throws DataFormatException
IllegalArgumentException
DataFormatException
Method Detail |
---|
public static NID generateNID(Hash h, int p, RandomSource random)
IllegalArgumentException
public int length()
SimpleDataStructure
length
in class SimpleDataStructure
public NID getNID()
public Destination getDestination()
public Hash getHash()
public Hash calculateHash()
DataStructure
calculateHash
in interface DataStructure
calculateHash
in class SimpleDataStructure
public void setDestination(Destination dest) throws IllegalArgumentException
IllegalArgumentException
- if hash of dest doesn't match previous hashpublic int getPort()
public long lastSeen()
public int hashCode()
SimpleDataStructure
hashCode
in class SimpleDataStructure
public boolean equals(Object o)
SimpleDataStructure
equals
in class SimpleDataStructure
public String toString()
toString
in class SimpleDataStructure
public String toPersistentString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |