-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemotePeerInfo.java
73 lines (69 loc) · 1.65 KB
/
RemotePeerInfo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.util.Date;
public class RemotePeerInfo implements Comparable<RemotePeerInfo>
{
public String peerId;
public String peerAddress;
public String peerPort;
public int isFirstPeer;
public double dataRate = 0;
public int isInterested = 1;
public int isPreferredNeighbor = 0;
public int isOptUnchokedNeighbor = 0;
public int isChoked = 1;
public BitField bitField;
public int state = -1;
public int peerIndex;
public int isCompleted = 0;
public int isHandShaked = 0;
public Date startTime;
public Date finishTime;
public RemotePeerInfo(String pId, String pAddress, String pPort, int pIndex)
{
peerId = pId;
peerAddress = pAddress;
peerPort = pPort;
bitField = new BitField();
peerIndex = pIndex;
}
public RemotePeerInfo(String pId, String pAddress, String pPort, int pIsFirstPeer, int pIndex)
{
peerId = pId;
peerAddress = pAddress;
peerPort = pPort;
isFirstPeer = pIsFirstPeer;
bitField = new BitField();
peerIndex = pIndex;
}
public String getPeerId() {
return peerId;
}
public void setPeerId(String peerId) {
this.peerId = peerId;
}
public String getPeerAddress() {
return peerAddress;
}
public void setPeerAddress(String peerAddress) {
this.peerAddress = peerAddress;
}
public String getPeerPort() {
return peerPort;
}
public void setPeerPort(String peerPort) {
this.peerPort = peerPort;
}
public int getIsFirstPeer() {
return isFirstPeer;
}
public void setIsFirstPeer(int isFirstPeer) {
this.isFirstPeer = isFirstPeer;
}
public int compareTo(RemotePeerInfo o1) {
if (this.dataRate > o1.dataRate)
return 1;
else if (this.dataRate == o1.dataRate)
return 0;
else
return -1;
}
}