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();
}
Aggregations