Skip to content

Instantly share code, notes, and snippets.

@mrtrkmn
Created January 8, 2019 19:42
Show Gist options
  • Save mrtrkmn/2cbe5ccbd0e0a05bffddacc5ed05cd73 to your computer and use it in GitHub Desktop.
Save mrtrkmn/2cbe5ccbd0e0a05bffddacc5ed05cd73 to your computer and use it in GitHub Desktop.
Blockchain Assignment 2 - Consensus from Trust
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
// Ahmet Turkmen / 110510016
/* CompliantNode refers to a node that follows the rules (not malicious)*/
public class CompliantNode implements Node {
private Set<Transaction> Transactions;
int n_r;
int c_r;
public CompliantNode(double p_graph, double p_malicious, double p_txDistribution, int numRounds) {
// IMPLEMENT THIS
this.n_r = numRounds;
this.c_r = 0;
}
public void setFollowees(boolean[] followees) {
// IMPLEMENT THIS
}
public void setPendingTransaction(Set<Transaction> pendingTransactions) {
// IMPLEMENT THIS
this.Transactions = pendingTransactions;
}
public Set<Transaction> sendToFollowers() {
// IMPLEMENT THIS
return Transactions;
}
public void receiveFromFollowees(Set<Candidate> candidates) {
// IMPLEMENT THIS
c_r++;
if ( c_r + 2 >= n_r) {
return;
}
for (Candidate can : candidates) {
Transactions.add(can.tx);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment