Search in sources :

Example 6 with ServiceEndpoint

use of com.hederahashgraph.api.proto.java.ServiceEndpoint in project hedera-services by hashgraph.

the class HfsSystemFilesManagerTest method legacyBookConstruction.

private static final NodeAddressBook legacyBookConstruction(final AddressBook fromBook) {
    final var builder = NodeAddressBook.newBuilder();
    for (int i = 0; i < fromBook.getSize(); i++) {
        final var address = fromBook.getAddress(i);
        final var publicKey = address.getSigPublicKey();
        final var nodeIP = address.getAddressExternalIpv4();
        final var nodeIPStr = Address.ipString(nodeIP);
        final var memo = address.getMemo();
        final var nodeAddress = NodeAddress.newBuilder().setIpAddress(ByteString.copyFromUtf8(nodeIPStr)).setMemo(ByteString.copyFromUtf8(memo)).setRSAPubKey(CommonUtils.hex(publicKey.getEncoded())).setNodeId(address.getId()).setStake(address.getStake());
        final var serviceEndpoint = ServiceEndpoint.newBuilder().setIpAddressV4(ByteString.copyFrom(address.getAddressExternalIpv4())).setPort(address.getPortExternalIpv4());
        nodeAddress.addServiceEndpoint(serviceEndpoint);
        setNodeAccountIfAvailforAddressBook(address, nodeAddress);
        builder.addNodeAddress(nodeAddress);
    }
    return builder.build();
}
Also used : ServiceEndpoint(com.hederahashgraph.api.proto.java.ServiceEndpoint)

Aggregations

ServiceEndpoint (com.hederahashgraph.api.proto.java.ServiceEndpoint)6 AddressBookServiceEndpoint (com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint)4 NodeAddress (com.hederahashgraph.api.proto.java.NodeAddress)3 ByteString (com.google.protobuf.ByteString)2 NodeAddressBook (com.hederahashgraph.api.proto.java.NodeAddressBook)2 ArrayList (java.util.ArrayList)2 StatusRuntimeException (io.grpc.StatusRuntimeException)1 HashSet (java.util.HashSet)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1