|
||||||||||
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,
InputStream in,
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 | |
---|---|
(package private) void |
cancel(int piece)
Tell the other side that we are no longer interested in any of the outstanding requests (if any) for this piece. |
int |
compareTo(Object o)
Deprecated. unused? |
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(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. |
String |
getSocket()
|
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. |
(package private) boolean |
isRequesting(int p)
Are we currently requesting the piece? |
void |
keepAlive()
Send keepalive |
(package private) void |
request()
Update the request queue. |
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)
Deprecated. unused |
void |
setRateHistory(long up,
long down)
Push the total uploaded/downloaded onto a RATE_DEPTH deep stack |
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 IOException
IOException
public Peer(I2PSocket sock, InputStream in, OutputStream out, byte[] my_id, MetaInfo metainfo) throws IOException
IOException
- when an error occurred during the handshake.Method Detail |
---|
public PeerID getPeerID()
public String toString()
toString
in class Object
public String getSocket()
public int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
public int compareTo(Object o)
compareTo
in interface 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)
void cancel(int piece)
boolean isRequesting(int p)
void request()
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 |