-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPeerRecord.java
43 lines (37 loc) · 1.03 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
import java.io.*;
import java.net.*;
import java.nio.*;
import java.util.*;
import java.util.concurrent.*;
/*
Class that will hold information about the local processes's Peers
*/
public class PeerRecord {
public int peerID;
public String host;
public int portNumber;
public boolean hasFile;
public DataInputStream inStream;
public DataOutputStream outStream;
public Socket socket;
public BitField bitField;
public int piecesSinceLastRound;
public boolean sentHandShake;
public boolean isInterested;
public boolean interestedIn;
public boolean isChoked;
public boolean isOptimisticallyUnchoked;
public PeerRecord(int peerID, String host, int portNumber, boolean hasFile, int pieceCount) {
this.peerID = peerID;
this.host = host;
this.portNumber = portNumber;
this.hasFile = hasFile;
this.sentHandShake = false;
this.bitField = new BitField(pieceCount);
this.isInterested = false;
this.piecesSinceLastRound = 0;
this.isChoked = true;
this.isOptimisticallyUnchoked = false;
this.interestedIn = false;
}
}