use of com.hedera.hashgraph.sdk.Status in project hedera-mirror-node by hashgraph.
the class TransactionPublisher method validateNode.
boolean validateNode(NodeProperties node) {
try {
log.info("Validating node {}", node);
Hbar hbar = Hbar.fromTinybars(1L);
AccountId nodeAccountId = AccountId.fromString(node.getAccountId());
Client client = validationClient.get();
Status receiptStatus = new TransferTransaction().addHbarTransfer(nodeAccountId, hbar).addHbarTransfer(client.getOperatorAccountId(), hbar.negated()).setNodeAccountIds(node.getAccountIds()).execute(client).getReceipt(client).status;
if (receiptStatus == SUCCESS) {
log.info("Validated node {} successfully", nodeAccountId);
nodes.addIfAbsent(node);
return true;
}
log.warn("Unable to validate node {}: invalid status code {}", node, receiptStatus);
} catch (TimeoutException e) {
log.warn("Unable to validate node {}: Timed out", node);
} catch (Exception e) {
log.warn("Unable to validate node {}: ", node, e);
}
nodes.remove(node);
return false;
}
Aggregations