Skip to content

Commit

Permalink
Revert "feat: allowing the system to use or not use reputation"
Browse files Browse the repository at this point in the history
This reverts commit 88afdc6.
  • Loading branch information
AllanCapistrano committed Mar 24, 2024
1 parent f012608 commit 528645d
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions src/main/java/reputation/node/models/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public class Node implements NodeTypeService, ILedgerSubscriber {
private boolean isNodesCredibilityWithSourceEmpty = true;
private boolean useCredibility;
private boolean useLatestCredibility;
private boolean useReputation;
private double reputationValue;
private NodeCredibility nodeCredibility;
private CsvWriterService csvWriter;
Expand Down Expand Up @@ -303,31 +302,18 @@ public void useNodeService() {
this.setRequestingNodeServices(false);
this.setLastNodeServiceTransactionType(null);
} else {
String nodeId = null;
String highestReputationNodeId = this.getNodeIdWithHighestReputation();

if (this.useReputation) {
nodeId = this.getNodeIdWithHighestReputation();
} else {
if (this.nodesWithServices.size() == 1) {
nodeId = this.nodesWithServices.get(0).getSource();
} else if (this.nodesWithServices.size() > 1) {
/* Escolhendo o provedor do serviço de maneira aleatória. */
int randomIndex = new Random().nextInt(this.nodesWithServices.size());

nodeId = this.nodesWithServices.get(randomIndex).getSource();
} else {
logger.severe("Invalid amount of service provider nodes.");
}
}

if (nodeId != null) {
final String innerNodeId = String.valueOf(nodeId);
if (highestReputationNodeId != null) {
final String innerHighestReputationNodeId = String.valueOf(
highestReputationNodeId
);

/**
* Obtendo a transação do nó que prestará o serviço.
* Obtendo a transação do nó com a maior reputação.
*/
ReputationService nodeWithService = (ReputationService) this.nodesWithServices.stream()
.filter(nws -> nws.getSource().equals(innerNodeId))
.filter(nws -> nws.getSource().equals(innerHighestReputationNodeId))
.collect(Collectors.toList())
.get(0);

Expand Down Expand Up @@ -1391,12 +1377,4 @@ public void setChangeDisturbingNodeBehaviorFlag(
) {
this.changeDisturbingNodeBehaviorFlag = changeDisturbingNodeBehaviorFlag;
}

public boolean isUseReputation() {
return useReputation;
}

public void setUseReputation(boolean useReputation) {
this.useReputation = useReputation;
}
}

0 comments on commit 528645d

Please sign in to comment.