Skip to content

Commit

Permalink
fix: calculating credibility when 'R' is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanCapistrano committed Mar 10, 2024
1 parent d006c38 commit 749bfbf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/java/reputation/node/models/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class Node implements NodeTypeService, ILedgerSubscriber {
private String lastNodeServiceTransactionType = null;
private boolean isRequestingNodeServices = false;
private boolean canReceiveNodesResponse = false;
private boolean isAverageEvaluationZero = false;
private boolean isNodesCredibilityWithSourceEmpty = true;
private boolean useCredibility;
private boolean useLatestCredibility;
private double reputationValue;
Expand Down Expand Up @@ -805,10 +805,10 @@ private float calculateCredibility(
logger.info(String.valueOf(nodeCredibility));

/**
* Calculando a credibilidade do nó avaliador, somente se o provedor de
* Calculando a credibilidade do nó avaliador, somente se o provedor de
* serviço tenha recebido avaliações previamente.
*/
if (!this.isAverageEvaluationZero) {
if (!this.isNodesCredibilityWithSourceEmpty) {
if (
consistency <= consistencyThreshold &&
trustworthiness <= trustworthinessThreshold
Expand Down Expand Up @@ -974,7 +974,8 @@ private float calculateTrustworthiness(
logger.info(String.valueOf(R));
}

this.isAverageEvaluationZero = (R == 0.0) ? true : false;
this.isNodesCredibilityWithSourceEmpty =
nodesCredibilityWithSource.isEmpty();

return Math.abs(currentServiceEvaluation - R);
}
Expand Down

0 comments on commit 749bfbf

Please sign in to comment.