use of com.hedera.hashgraph.sdk.proto.NodeAddress in project hedera-mirror-node by hashgraph.
the class SDKClient method getAddressBookNetworkMap.
private Map<String, AccountId> getAddressBookNetworkMap(Client client) throws InvalidProtocolBufferException, PrecheckStatusException, TimeoutException {
NodeAddressBook addressBook = getAddressBookFromNetwork(client);
Map<String, AccountId> networkMap = new HashMap<>();
for (NodeAddress nodeAddressProto : addressBook.getNodeAddressList()) {
networkMap.putIfAbsent(String.format("%s:%d", nodeAddressProto.getIpAddress().toStringUtf8(), nodeAddressProto.getPortno()), new AccountId(nodeAddressProto.getNodeAccountId().getShardNum(), nodeAddressProto.getNodeAccountId().getRealmNum(), nodeAddressProto.getNodeAccountId().getAccountNum()));
}
log.debug("Obtained addressBook networkMap: {}", networkMap);
return networkMap;
}
Aggregations