use of com.hedera.hashgraph.sdk.Client in project hedera-mirror-node by hashgraph.
the class SDKClient method toClient.
private Client toClient(Map<String, AccountId> network) throws InterruptedException {
Client client = Client.forNetwork(network);
client.setOperator(expandedOperatorAccountId.getAccountId(), expandedOperatorAccountId.getPrivateKey());
client.setMirrorNetwork(List.of(acceptanceTestProperties.getMirrorNodeAddress()));
return client;
}
use of com.hedera.hashgraph.sdk.Client in project hedera-mirror-node by hashgraph.
the class SDKClient method validateNode.
private boolean validateNode(String endpoint, AccountId nodeAccountId) {
boolean valid = false;
try (Client client = toClient(Map.of(endpoint, nodeAccountId))) {
new AccountBalanceQuery().setAccountId(nodeAccountId).setNodeAccountIds(List.of(nodeAccountId)).execute(client, Duration.ofSeconds(10L));
log.debug("Validated node: {}", nodeAccountId);
valid = true;
} catch (Exception e) {
log.warn("Unable to validate node {}: ", nodeAccountId, e.getMessage());
}
return valid;
}
use of com.hedera.hashgraph.sdk.Client in project hedera-mirror-node by hashgraph.
the class SDKClient method getNetworkMap.
private Map<String, AccountId> getNetworkMap() {
var customNodes = acceptanceTestProperties.getNodes();
var network = acceptanceTestProperties.getNetwork();
if (!CollectionUtils.isEmpty(customNodes)) {
log.debug("Creating SDK client for {} network with nodes: {}", network, customNodes);
return getNetworkMap(customNodes);
}
if (acceptanceTestProperties.isRetrieveAddressBook()) {
try {
return getAddressBook();
} catch (Exception e) {
log.warn("Error retrieving address book", e);
}
}
Client client = Client.forName(network.toString().toLowerCase());
return client.getNetwork();
}
use of com.hedera.hashgraph.sdk.Client in project hedera-mirror-node by hashgraph.
the class TransactionPublisher method toClient.
private Client toClient(Map<String, AccountId> nodes) {
AccountId operatorId = AccountId.fromString(monitorProperties.getOperator().getAccountId());
PrivateKey operatorPrivateKey = PrivateKey.fromString(monitorProperties.getOperator().getPrivateKey());
Client client = Client.forNetwork(nodes);
client.setNodeMaxBackoff(publishProperties.getNodeMaxBackoff());
client.setOperator(operatorId, operatorPrivateKey);
return client;
}
use of com.hedera.hashgraph.sdk.Client in project hedera-mirror-node by hashgraph.
the class TransactionPublisher method close.
@Override
public void close() {
if (nodeValidator.get() != null) {
nodeValidator.get().dispose();
}
if (publishProperties.isEnabled()) {
log.warn("Closing {} clients", publishProperties.getClients());
clients.subscribe(client -> {
try {
client.close();
} catch (Exception e) {
// Ignore
}
});
Client client = validationClient.get();
if (client != null) {
try {
client.close();
} catch (Exception e) {
// Ignore
}
}
}
}
Aggregations