Skip to content

Commit

Permalink
fix: selfish credibility
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanCapistrano committed Jul 27, 2024
1 parent eb2a65a commit 8192966
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/main/java/reputation/node/models/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,10 @@ private float calculateCredibility(
* Calculando a credibilidade do nó avaliador, somente se o provedor de
* serviço tenha recebido avaliações previamente.
*/
if (!this.isNodesCredibilityWithSourceEmpty) {
if (
!this.isNodesCredibilityWithSourceEmpty &&
!this.getNodeType().getType().toString().equals("SELFISH")
) {
if (
consistency <= consistencyThreshold &&
trustworthiness <= trustworthinessThreshold
Expand Down Expand Up @@ -938,15 +941,19 @@ private float calculateCredibility(

/* Escrevendo na blockchain a credibilidade calculado do nó avaliador */
try {
Transaction credibilityTransaction = new Credibility(
sourceId,
this.getNodeType().getNodeGroup(),
TransactionType.REP_CREDIBILITY,
nodeCredibility
);
if (!this.getNodeType().getType().toString().equals("SELFISH")) {
Transaction credibilityTransaction = new Credibility(
sourceId,
this.getNodeType().getNodeGroup(),
TransactionType.REP_CREDIBILITY,
nodeCredibility
);

this.ledgerConnector.getLedgerWriter()
.put(new IndexTransaction("cred_" + sourceId, credibilityTransaction));
this.ledgerConnector.getLedgerWriter()
.put(
new IndexTransaction("cred_" + sourceId, credibilityTransaction)
);
}
} catch (InterruptedException ie) {
logger.warning("Unable to write the node credibility on blockchain");
logger.warning(ie.getMessage());
Expand Down

0 comments on commit 8192966

Please sign in to comment.