|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.klomp.snark.Peer
public class Peer
Field Summary | |
---|---|
(package private) static long |
CHECK_PERIOD
|
(package private) MetaInfo |
metainfo
|
(package private) static int |
RATE_DEPTH
|
(package private) PeerState |
state
|
Constructor Summary | |
---|---|
Peer(I2PSocket sock,
java.io.InputStream in,
java.io.OutputStream out,
byte[] my_id,
MetaInfo metainfo)
Creates a unconnected peer from the input and output stream got from the socket. |
|
Peer(PeerID peerID,
byte[] my_id,
MetaInfo metainfo)
Creates a disconnected peer given a PeerID, your own id and the relevant MetaInfo. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object o)
Compares the PeerIDs. |
int |
completed()
Return how much the peer has |
(package private) void |
disconnect()
|
void |
disconnect(boolean deregister)
Disconnects this peer if it was connected. |
boolean |
equals(java.lang.Object o)
Two Peers are equal when they have the same PeerID. |
long |
getDownloaded()
Returns the number of bytes that have been downloaded. |
long |
getDownloadRate()
|
long |
getInactiveTime()
|
PeerID |
getPeerID()
Returns the id of the peer. |
java.lang.String |
getSocket()
Returns socket (for debug printing) |
long |
getUploaded()
Returns the number of bytes that have been uploaded. |
long |
getUploadRate()
Returns the 4-minute-average rate in Bps |
int |
hashCode()
The hash code of a Peer is the hash code of the peerID. |
void |
have(int piece)
Tell the peer we have another piece. |
boolean |
isChoked()
Whether or not the peer choked us. |
boolean |
isChoking()
Whether or not we are choking the peer. |
boolean |
isCompleted()
Return if a peer is a seeder |
boolean |
isConnected()
|
boolean |
isInterested()
Whether or not the peer is interested in pieces we have. |
boolean |
isInteresting()
Whether or not the peer has pieces we want from it. |
void |
keepAlive()
Send keepalive |
void |
resetCounters()
Resets the downloaded and uploaded counters to zero. |
void |
retransmitRequests()
Retransmit outstanding requests if necessary |
void |
runConnection(I2PSnarkUtil util,
PeerListener listener,
BitField bitfield)
Runs the connection to the other peer. |
void |
setChoking(boolean choke)
Sets whether or not we are choking the peer. |
void |
setInteresting(boolean interest)
Sets whether or not we are interested in pieces from this peer. |
void |
setRateHistory(long up,
long down)
Push the total uploaded/downloaded onto a RATE_DEPTH deep stack |
java.lang.String |
toString()
Returns the String representation of the peerID. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
final MetaInfo metainfo
PeerState state
static final long CHECK_PERIOD
static final int RATE_DEPTH
Constructor Detail |
---|
public Peer(PeerID peerID, byte[] my_id, MetaInfo metainfo) throws java.io.IOException
java.io.IOException
public Peer(I2PSocket sock, java.io.InputStream in, java.io.OutputStream out, byte[] my_id, MetaInfo metainfo) throws java.io.IOException
java.io.IOException
- when an error occurred during the handshake.Method Detail |
---|
public PeerID getPeerID()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getSocket()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public void runConnection(I2PSnarkUtil util, PeerListener listener, BitField bitfield)
public boolean isConnected()
public void disconnect(boolean deregister)
void disconnect()
public void have(int piece)
public boolean isInterested()
public void setInteresting(boolean interest)
public boolean isInteresting()
public void setChoking(boolean choke)
public boolean isChoking()
public boolean isChoked()
public long getDownloaded()
resetCounters()
/
public long getUploaded()
resetCounters()
/
public void resetCounters()
public long getInactiveTime()
public void keepAlive()
public void retransmitRequests()
public int completed()
public boolean isCompleted()
public void setRateHistory(long up, long down)
public long getUploadRate()
public long getDownloadRate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |