From 8192966a6c198dfcb0449717cb6d1815cc172c5e Mon Sep 17 00:00:00 2001 From: AllanCapistrano Date: Sat, 27 Jul 2024 18:52:50 -0300 Subject: [PATCH] fix: selfish credibility --- .../java/reputation/node/models/Node.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/reputation/node/models/Node.java b/src/main/java/reputation/node/models/Node.java index 365cbac..43761af 100644 --- a/src/main/java/reputation/node/models/Node.java +++ b/src/main/java/reputation/node/models/Node.java @@ -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 @@ -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());