-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompliantNode.java
36 lines (28 loc) · 1.04 KB
/
CompliantNode.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
package bitcoin;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
/* CompliantNode refers to a node that follows the rules (not malicious)*/
public class CompliantNode implements Node {
private boolean[] followees;
private Set<Transaction> pendingTransactions = new HashSet<>();
public CompliantNode(double p_graph, double p_malicious, double p_txDistribution, int numRounds) {
// IMPLEMENT THIS
}
public void setFollowees(boolean[] followees) {
this.followees = followees;
}
public void setPendingTransaction(Set<Transaction> pendingTransactions) {
this.pendingTransactions = pendingTransactions;
}
public Set<Transaction> sendToFollowers() {
return this.pendingTransactions;
}
public void receiveFromFollowees(Set<Candidate> candidates) {
for (Candidate candidate : candidates) {
if (this.followees[candidate.sender]) {
this.pendingTransactions.add(candidate.tx);
}
}
}
}