-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPeerRecord.java
72 lines (55 loc) · 1.71 KB
/
PeerRecord.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
/* Le Hénaff Pablo ; Basudan Hossam*/
import java.net.InetAddress;
import java.time.Instant;
public class PeerRecord {
private String peerID;
private String peerIPAddress;
private int peerSeqNum;
private Instant expirationTime;
private String peerState;
public PeerRecord(HelloMessage helloMessage, String IPAddress){
peerID = helloMessage.getSenderID();
peerIPAddress = IPAddress;
//TODO verify problem sending first hello
peerSeqNum =-1;
peerSeqNum =-1;
expirationTime= Instant.now().plusSeconds(helloMessage.getHelloInterval());
peerState = "heard";
}
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PeerRecord that = (PeerRecord) o;
// return (peerID != null ? !peerID.equals(that.peerID) : that.peerID != null);
// }
public String getPeerID() {
return peerID;
}
public String getPeerIPAddress() {
return peerIPAddress;
}
public int getPeerSeqNum() {
return peerSeqNum;
}
public void setPeerSeqNum(int peerSeqNum) {
this.peerSeqNum = peerSeqNum;
}
public Instant getExpirationTime() {
return expirationTime;
}
public void setExpirationTime(Instant expirationTime) {
this.expirationTime=expirationTime;
}
public String getPeerState() {
return peerState;
}
public void setPeerState(String peerState){
this.peerState= peerState;
}
@Override
public String toString() {
return peerID+";"+peerIPAddress+";"+peerSeqNum+";"+expirationTime+";"+peerState+"\n";
}
}