Skip to content

Commit

Permalink
chore: using IndexTransaction instead of Transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanCapistrano committed Oct 12, 2023
1 parent 5801188 commit 78c0d1b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/main/java/node/type/models/conducts/Honest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package node.type.models.conducts;

// TODO: Corrigir package em todas as classes.

import dlt.client.tangle.hornet.enums.TransactionType;
import dlt.client.tangle.hornet.model.transactions.Evaluation;
import dlt.client.tangle.hornet.model.transactions.IndexTransaction;
import dlt.client.tangle.hornet.model.transactions.Transaction;
import java.util.logging.Logger;
import node.type.enums.ConductType;
import node.type.models.tangle.LedgerConnector;

import java.util.logging.Logger;

public class Honest extends Conduct {

private static final Logger logger = Logger.getLogger(Honest.class.getName());
Expand Down Expand Up @@ -63,6 +64,7 @@ public void evaluateDevice(String deviceId, int value)
);

// Adicionando avaliação na Tangle.
this.getLedgerConnector().put(transactionEvaluation);
this.getLedgerConnector()
.put(new IndexTransaction(deviceId, transactionEvaluation));
}
}
9 changes: 5 additions & 4 deletions src/main/java/node/type/models/conducts/Malicious.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import dlt.client.tangle.hornet.enums.TransactionType;
import dlt.client.tangle.hornet.model.transactions.Evaluation;
import dlt.client.tangle.hornet.model.transactions.IndexTransaction;
import dlt.client.tangle.hornet.model.transactions.Transaction;
import node.type.enums.ConductType;
import node.type.models.tangle.LedgerConnector;

import java.util.Random;
import java.util.logging.Logger;
import node.type.enums.ConductType;
import node.type.models.tangle.LedgerConnector;

public class Malicious extends Conduct {

Expand Down Expand Up @@ -100,7 +100,8 @@ public void evaluateDevice(String deviceId, int value)
);

// Adicionando avaliação na Tangle.
this.getLedgerConnector().put(transactionEvaluation);
this.getLedgerConnector()
.put(new IndexTransaction(deviceId, transactionEvaluation));
}

public float getHonestyRate() {
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/node/type/models/tangle/LedgerConnector.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package node.type.models.tangle;

import dlt.client.tangle.hornet.model.transactions.IndexTransaction;
import dlt.client.tangle.hornet.model.transactions.Transaction;
import dlt.client.tangle.hornet.services.ILedgerReader;
import dlt.client.tangle.hornet.services.ILedgerSubscriber;
Expand Down Expand Up @@ -36,11 +37,13 @@ public void unsubscribe(String topic, ILedgerSubscriber iLedgerSubscriber) {
/**
* Põe uma transação para ser publicada na Tangle.
*
* @param transaction Transaction - Transação que será publicada.
* @param indexTransaction IndexTransaction - Transação que será publicada,
* juntamente com seu índice.
* @throws InterruptedException
*/
public void put(Transaction transaction) throws InterruptedException {
this.ledgerWriter.put(transaction);
public void put(IndexTransaction indexTransaction)
throws InterruptedException {
this.ledgerWriter.put(indexTransaction);
}

/**
Expand Down

0 comments on commit 78c0d1b

Please sign in to comment.