Skip to content

Commit

Permalink
Merge pull request #18 from AllanCapistrano/fix/selfish-publishing-cr…
Browse files Browse the repository at this point in the history
…edibility

fix: selfish credibility
  • Loading branch information
AllanCapistrano authored Jul 27, 2024
2 parents eb2a65a + 8192966 commit 80052e9
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 80052e9

Please sign in to comment.