|
14 | 14 | * limitations under the License.
|
15 | 15 | *
|
16 | 16 | */
|
17 |
| -import * as HashgraphProto from '@hashgraph/proto' |
18 | 17 | import * as Base64 from 'js-base64'
|
19 | 18 | import os from 'os'
|
20 | 19 | import * as constants from './constants.mjs'
|
@@ -626,43 +625,7 @@ export class AccountManager {
|
626 | 625 | async prepareAddressBookBase64 (namespace) {
|
627 | 626 | // fetch AddressBook
|
628 | 627 | const fileQuery = new FileContentsQuery().setFileId(FileId.ADDRESS_BOOK)
|
629 |
| - let addressBookBytes = await fileQuery.execute(this._nodeClient) |
630 |
| - |
631 |
| - /** @type {Map<string, NetworkNodeServices>} **/ |
632 |
| - const networkNodeServicesMap = await this.getNodeServiceMap(namespace) |
633 |
| - |
634 |
| - // ensure serviceEndpoint.ipAddressV4 value for all nodes in the addressBook is a 4 bytes array instead of string |
635 |
| - // See: https://github.com/hashgraph/hedera-protobufs/blob/main/services/basic_types.proto#L1309 |
636 |
| - // TODO: with v0.53 will mirror node no longer need this and we can remove @hashgraph/proto: https://github.com/hashgraph/solo/issues/493 |
637 |
| - const addressBook = HashgraphProto.proto.NodeAddressBook.decode(addressBookBytes) |
638 |
| - const hasAlphaRegEx = /[a-zA-Z]+/ |
639 |
| - let modified = false |
640 |
| - for (const nodeAddress of addressBook.nodeAddress) { |
641 |
| - const address = nodeAddress.serviceEndpoint[0].ipAddressV4.toString() |
642 |
| - |
643 |
| - if (hasAlphaRegEx.test(address)) { |
644 |
| - const nodeId = Templates.nodeIdFromFullyQualifiedNetworkSvcName(address) |
645 |
| - nodeAddress.serviceEndpoint[0].ipAddressV4 = Uint8Array.from(ip.toBuffer(networkNodeServicesMap.get(nodeId).nodeServiceClusterIp)) |
646 |
| - nodeAddress.ipAddress = Uint8Array.from(ip.toBuffer(networkNodeServicesMap.get(nodeId).nodeServiceClusterIp)) |
647 |
| - modified = true |
648 |
| - continue |
649 |
| - } |
650 |
| - // overwrite ipAddressV4 as 4 bytes array if required, unless there is alpha, which means it is a domain name |
651 |
| - if (nodeAddress.serviceEndpoint[0].ipAddressV4.byteLength !== 4) { |
652 |
| - const parts = address.split('.') |
653 |
| - |
654 |
| - if (parts.length !== 4) { |
655 |
| - throw new FullstackTestingError(`expected node IP address to have 4 parts, found ${parts.length}: ${address}`) |
656 |
| - } |
657 |
| - |
658 |
| - nodeAddress.serviceEndpoint[0].ipAddressV4 = Uint8Array.from(parts) |
659 |
| - modified = true |
660 |
| - } |
661 |
| - } |
662 |
| - |
663 |
| - if (modified) { |
664 |
| - addressBookBytes = HashgraphProto.proto.NodeAddressBook.encode(addressBook).finish() |
665 |
| - } |
| 628 | + const addressBookBytes = await fileQuery.execute(this._nodeClient) |
666 | 629 |
|
667 | 630 | // convert addressBook into base64
|
668 | 631 | return Base64.encode(addressBookBytes)
|
|
0 commit comments