Search in sources :

Example 1 with NodeAddress

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;
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) ExpandedAccountId(com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NodeAddressBook(com.hedera.hashgraph.sdk.proto.NodeAddressBook) NodeAddress(com.hedera.hashgraph.sdk.proto.NodeAddress) ByteString(com.google.protobuf.ByteString)

Aggregations

ByteString (com.google.protobuf.ByteString)1 AccountId (com.hedera.hashgraph.sdk.AccountId)1 NodeAddress (com.hedera.hashgraph.sdk.proto.NodeAddress)1 NodeAddressBook (com.hedera.hashgraph.sdk.proto.NodeAddressBook)1 ExpandedAccountId (com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1