Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/blockchain node communication zqm #10

Merged
merged 52 commits into from
Dec 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
af9c3c9
chore: deleting unused class
AllanCapistrano Oct 26, 2023
3a6db15
chore: update NodeServiceType
AllanCapistrano Oct 26, 2023
8ceb655
feat: create publishNodeServices and removing unnecessary methods
AllanCapistrano Oct 26, 2023
2ec9ec9
chore: removing unused properties and add publishNodeServiceTaskTime
AllanCapistrano Oct 27, 2023
203c743
feat: create PublishNodeServicesTask
AllanCapistrano Oct 27, 2023
e92b7b9
fix: pubishNodeServices and removing unused timeouts
AllanCapistrano Oct 27, 2023
93eabd2
feat: using nodeIp
AllanCapistrano Oct 27, 2023
fb5b727
feat: create getNodesServices
AllanCapistrano Oct 31, 2023
78c5c79
chore: removing unused things
AllanCapistrano Oct 31, 2023
5e3ddfc
feat: create CheckNodesServicesTask
AllanCapistrano Oct 31, 2023
6b4f9ae
feat: add checkNodesServicesTaskTime property
AllanCapistrano Oct 31, 2023
d014082
chore: using CheckNodesServicesTask
AllanCapistrano Oct 31, 2023
64d3ce9
feat: add TODO
AllanCapistrano Oct 31, 2023
b1e446f
chore: removing unused classes, variables and methods
AllanCapistrano Nov 9, 2023
68e2e67
fix: ReputationService constructor
AllanCapistrano Nov 9, 2023
79a17d7
feat: create checkNodesServicesTaskTime
AllanCapistrano Nov 9, 2023
473e686
feat: create CheckNodesServicesTask
AllanCapistrano Nov 9, 2023
e8e1027
feat: start to develop node service
AllanCapistrano Nov 9, 2023
83f3ace
fix: node service type
AllanCapistrano Nov 10, 2023
6a2c099
fix: communication between nodes by tangle hornet
AllanCapistrano Nov 10, 2023
f15564a
chore: checking if a request is in progress
AllanCapistrano Nov 13, 2023
f08c33b
feat: check the response of node service provider and add new topics …
AllanCapistrano Nov 13, 2023
45663cc
feat: create WaitNodesResponsesTask
AllanCapistrano Nov 13, 2023
def69bb
feat: create waitNodesResponsesTaskTime property
AllanCapistrano Nov 13, 2023
99eaa84
chore: using WaitNodesResponsesTask
AllanCapistrano Nov 13, 2023
2a84de2
feat: create NodeReputation class
AllanCapistrano Nov 14, 2023
a94c177
feat: create checkNodesReputation method
AllanCapistrano Nov 14, 2023
ec07ec6
chore: using checkNodesReputation
AllanCapistrano Nov 14, 2023
11458b5
fix: invalid amount of nodes with highest reputation
AllanCapistrano Nov 15, 2023
b08fa2c
chore: set variables to default values if the process has not been co…
AllanCapistrano Nov 15, 2023
ae9cbc9
fix: evaluating devices when receive a FLOW message by MQTT
AllanCapistrano Nov 15, 2023
adabcbe
feat: create requestNodeService method
AllanCapistrano Nov 15, 2023
e281289
fix: check nodes services task when no node responds
AllanCapistrano Nov 16, 2023
2b6e3fe
feat: create enableDevicesPage and starting to evaluating the nodes
AllanCapistrano Nov 16, 2023
b0c66b9
fix: evatuation when request some node service
AllanCapistrano Nov 17, 2023
2deeb43
docs: add docs to enableDevicesPage and requestNodeService
AllanCapistrano Nov 17, 2023
c43bf5e
feat: create JsonStringToJsonObject class
AllanCapistrano Nov 17, 2023
2f7bfae
chore: using JsonStringToJsonObject
AllanCapistrano Nov 17, 2023
8730544
refactor: start and publishNodeServices methods
AllanCapistrano Nov 17, 2023
0c43581
chore: change class name
AllanCapistrano Nov 25, 2023
ade96d8
chore: update get and set method name
AllanCapistrano Nov 25, 2023
4511fe0
feat: create getDeviceWithHighestReputation method
AllanCapistrano Nov 26, 2023
6d36bc6
docs: add docs to getDeviceWithHighestReputation
AllanCapistrano Nov 26, 2023
e386db5
chore: renaming method
AllanCapistrano Nov 26, 2023
67f37cd
refactor: usenodeService method
AllanCapistrano Nov 26, 2023
9b1503d
fix: thing id with highest reputation index
AllanCapistrano Nov 26, 2023
f5eb5c1
feat: create ReputationCalc class and interface
AllanCapistrano Nov 26, 2023
68ace07
chore: using reputation calc
AllanCapistrano Nov 27, 2023
6af6bf0
fix: starvation problem on the device list
AllanCapistrano Nov 27, 2023
bd3e161
chore: disabling evaluation JSON messages view
AllanCapistrano Nov 27, 2023
6f941c4
chore: removing TODO
AllanCapistrano Dec 10, 2023
68d7f22
chore: update class version
AllanCapistrano Dec 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: communication between nodes by tangle hornet
AllanCapistrano committed Nov 10, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6a2c0990f55a2c2377a83309b5e686206709dc85
79 changes: 39 additions & 40 deletions src/main/java/reputation/node/models/Node.java
Original file line number Diff line number Diff line change
@@ -156,18 +156,18 @@ public void requestDataFromRandomDevice() {
}

/**
* Publica na blockchain quais são os serviços providos pelo nó.
* Publica na blockchain quais são os serviços prestados pelo nó.
*
* @throws InterruptedException
*/
private void publishNodeServices(String serviceType, String target) {
logger.info("B");
/* Só responde se tiver pelo menos um dispositivo conectado ao nó. */
if (this.amountDevices > 0) {
logger.info("SERVICE TYPE: " + serviceType); // TODO: Remover
logger.info("Requested service type: " + serviceType);

Transaction transaction = null;
String transactionType = null;
TransactionType transactionType;
String transactionTypeInString = null;

List<DeviceSensorId> deviceSensorIdList = new ArrayList<>();

@@ -189,76 +189,86 @@ private void publishNodeServices(String serviceType, String target) {
if (
serviceType.equals(NodeServiceType.HUMIDITY_SENSOR.getDescription())
) {
transactionType = TransactionType.REP_SVC_HUMIDITY_SENSOR;

transaction =
new ReputationService(
this.nodeType.getNodeId(),
this.nodeType.getNodeIp(),
target,
deviceSensorIdList,
this.nodeType.getNodeGroup(),
TransactionType.REP_SVC_HUMIDITY_SENSOR
transactionType
);

transactionType = TransactionType.REP_SVC_HUMIDITY_SENSOR.name();
transactionTypeInString = transactionType.name();
} else if (
serviceType.equals(NodeServiceType.PULSE_OXYMETER.getDescription())
) {
transactionType = TransactionType.REP_SVC_PULSE_OXYMETER;

transaction =
new ReputationService(
this.nodeType.getNodeId(),
this.nodeType.getNodeIp(),
target,
deviceSensorIdList,
this.nodeType.getNodeGroup(),
TransactionType.REP_SVC_PULSE_OXYMETER
transactionType
);

transactionType = TransactionType.REP_SVC_PULSE_OXYMETER.name();
transactionTypeInString = transactionType.name();
} else if (
serviceType.equals(NodeServiceType.THERMOMETER.getDescription())
) {
transactionType = TransactionType.REP_SVC_THERMOMETER;

transaction =
new ReputationService(
this.nodeType.getNodeId(),
this.nodeType.getNodeIp(),
target,
deviceSensorIdList,
this.nodeType.getNodeGroup(),
TransactionType.REP_SVC_THERMOMETER
transactionType
);

transactionType = TransactionType.REP_SVC_THERMOMETER.name();
transactionTypeInString = transactionType.name();
} else if (
serviceType.equals(
NodeServiceType.WIND_DIRECTION_SENSOR.getDescription()
)
) {
transactionType = TransactionType.REP_SVC_WIND_DIRECTION_SENSOR;

transaction =
new ReputationService(
this.nodeType.getNodeId(),
this.nodeType.getNodeIp(),
target,
deviceSensorIdList,
this.nodeType.getNodeGroup(),
TransactionType.REP_SVC_WIND_DIRECTION_SENSOR
transactionType
);

transactionType = TransactionType.REP_SVC_WIND_DIRECTION_SENSOR.name();
transactionTypeInString = transactionType.name();
} else {
logger.severe("Unknown service type.");
}

/*
* Enviando a transação para a blockchain.
*/
if (transaction != null && transactionType != null) {
if (transaction != null && transactionTypeInString != null) {
try {
this.ledgerConnector.put(
new IndexTransaction(transactionType, transaction)
new IndexTransaction(transactionTypeInString, transaction)
);
} catch (InterruptedException ie) {
logger.warning(
"Error trying to create a " + transactionType + " transaction."
"Error trying to create a " +
transactionTypeInString +
" transaction."
);
logger.warning(ie.getStackTrace().toString());
}
@@ -381,31 +391,20 @@ private void subscribeToDevicesTopics(int amountNewDevices) {

@Override
public void update(Object object, Object object2) {
// String sourceReceivedTransaction = ((Transaction) object).getSource();

// if (!sourceReceivedTransaction.equals(this.getNodeType().getNodeId())) {
// logger.info("OLA");
// } else {
// logger.info("REMOVER");
// }

logger.info("UEEEE");
String sourceReceivedTransaction = ((Transaction) object).getSource();

// if (!sourceReceivedTransaction.equals(this.getNodeType().getNodeId())) {}

// TODO: Colocar dentro do 'if'
Transaction receivedTransaction = (Transaction) object;

logger.info("AAAAAA");
logger.info(receivedTransaction.getType().name());

if (receivedTransaction.getType() == TransactionType.REP_HAS_SVC) {
logger.info("A");
this.publishNodeServices(
((HasReputationService) receivedTransaction).getService(), // TODO: Esse método não foi chamado e aconteceu somente uma vez
receivedTransaction.getSource()
);
/**
* Somente caso a transação não tenha sido enviada pelo próprio nó.
*/
if (
!((Transaction) object).getSource().equals(this.getNodeType().getNodeId())
) {
if (((Transaction) object).getType() == TransactionType.REP_HAS_SVC) {
HasReputationService receivedTransaction = (HasReputationService) object;

this.publishNodeServices(
receivedTransaction.getService(),
receivedTransaction.getSource()
);
}
}
}