Skip to content

Commit 60a364d

Browse files
committed
some fixes
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent a2e6186 commit 60a364d

File tree

3 files changed

+19
-29
lines changed

3 files changed

+19
-29
lines changed

src/commands/node.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ export class NodeCommand extends BaseCommand {
6969

7070
static get SETUP_FLAGS_LIST () {
7171
return [
72-
flags.apiPermissionProperties, // TODO move
72+
flags.apiPermissionProperties, // TODO move to `network deploy`
7373
flags.app,
7474
flags.appConfig,
75-
flags.applicationProperties, // TODO move
76-
flags.bootstrapProperties, // TODO move
75+
flags.applicationProperties, // TODO move to `network deploy`
76+
flags.bootstrapProperties, // TODO move to `network deploy`
7777
flags.cacheDir,
7878
flags.chainId,
7979
flags.devMode,
@@ -82,11 +82,11 @@ export class NodeCommand extends BaseCommand {
8282
flags.generateTlsKeys,
8383
flags.keyFormat,
8484
flags.localBuildPath,
85-
flags.log4j2Xml, // TODO move
85+
flags.log4j2Xml, // TODO move to `network deploy`
8686
flags.namespace,
8787
flags.nodeIDs,
8888
flags.releaseTag,
89-
flags.settingTxt // TODO move
89+
flags.settingTxt // TODO move to `network deploy`
9090
]
9191
}
9292

src/core/helpers.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,13 @@ export async function getNodeLogs (k8, namespace) {
215215
}
216216
}
217217

218-
// a function generate map between the nodeId and their account ids
218+
/**
219+
* Create a map of node IDs to account IDs
220+
* @param nodeIDs an array of the node IDs
221+
* @returns {Map<string,string>} the map of node IDs to account IDs
222+
*/
219223
export function getNodeAccountMap (nodeIDs) {
220-
const accountMap = new Map()
224+
const accountMap = /** @type {Map<string,string>} **/ new Map()
221225
const realm = constants.HEDERA_NODE_ACCOUNT_ID_START.realm
222226
const shard = constants.HEDERA_NODE_ACCOUNT_ID_START.shard
223227
let accountId = constants.HEDERA_NODE_ACCOUNT_ID_START.num

src/core/profile_manager.mjs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ import dot from 'dot-object'
2424
import { getNodeAccountMap } from './helpers.mjs'
2525
import * as semver from 'semver'
2626

27-
/**
28-
* @typedef {Object} NodeInfo
29-
* @property {string} nodeName
30-
* @property {string} accountId
31-
*/
32-
3327
const consensusSidecars = [
3428
'recordStreamUploader', 'eventStreamUploader', 'backupUploader', 'accountBalanceUploader', 'otelCollector']
3529

@@ -158,18 +152,11 @@ export class ProfileManager {
158152

159153
const accountMap = getNodeAccountMap(nodeIds)
160154

161-
/** @type {Map<string, NodeInfo>} **/
162-
const nodeMap = new Map()
163-
164155
// set consensus pod level resources
165156
for (let nodeIndex = 0; nodeIndex < nodeIds.length; nodeIndex++) {
166-
const fullAccountId = `${realm}.${shard}.${accountId++}`
167-
168157
this._setValue(`hedera.nodes.${nodeIndex}.name`, nodeIds[nodeIndex], yamlRoot)
169-
this._setValue(`hedera.nodes.${nodeIndex}.accountId`, fullAccountId, yamlRoot)
158+
this._setValue(`hedera.nodes.${nodeIndex}.accountId`, accountMap.get(nodeIds[nodeIndex]), yamlRoot)
170159
this._setChartItems(`hedera.nodes.${nodeIndex}`, profile.consensus, yamlRoot)
171-
172-
nodeMap.set(nodeIds[nodeIndex], { nodeName: nodeIds[nodeIndex], accountId: fullAccountId })
173160
}
174161

175162
const stagingDir = Templates.renderStagingDir(this.configManager, flags)
@@ -385,16 +372,16 @@ export class ProfileManager {
385372
/**
386373
* Prepares config.txt file for the node
387374
* @param {string} namespace namespace where the network is deployed
388-
* @param {Map<string, NodeInfo>} nodeMap Map of NodeInfo objects
375+
* @param {Map<string, string>} nodeAccountMap the map of node IDs to account IDs
389376
* @param {string} destPath path to the destination directory to write the config.txt file
390377
* @param {string} releaseTag release tag e.g. v0.42.0
391378
* @param {string} appName the app name (default: HederaNode.jar)
392379
* @param {string} chainId chain ID (298 for local network)
393380
* @param {string} template path to the config.template file
394381
* @returns {string} the config.txt file path
395382
*/
396-
prepareConfigTxt (namespace, nodeMap, destPath, releaseTag, appName = constants.HEDERA_APP_NAME, chainId = constants.HEDERA_CHAIN_ID, template = `${constants.RESOURCES_DIR}/templates/config.template`) {
397-
if (!nodeMap || nodeMap.length === 0) throw new MissingArgumentError('map of NodeInfo objects is required')
383+
prepareConfigTxt (namespace, nodeAccountMap, destPath, releaseTag, appName = constants.HEDERA_APP_NAME, chainId = constants.HEDERA_CHAIN_ID, template = `${constants.RESOURCES_DIR}/templates/config.template`) {
384+
if (!nodeAccountMap || nodeAccountMap.length === 0) throw new MissingArgumentError('nodeAccountMap the map of node IDs to account IDs is required')
398385
if (!template) throw new MissingArgumentError('config templatePath is required')
399386
if (!releaseTag) throw new MissingArgumentError('release tag is required')
400387

@@ -415,16 +402,15 @@ export class ProfileManager {
415402
configLines.push(`app, ${appName}`)
416403

417404
let nodeSeq = 0
418-
for (const nodeInfo of nodeMap.values()) {
419-
const nodeName = nodeInfo.nodeId
420-
const nodeNickName = nodeInfo.nodeId
405+
for (const nodeID of nodeAccountMap.keys()) {
406+
const nodeName = nodeID
421407

422408
const internalIP = Templates.renderFullyQualifiedNetworkPodName(namespace, nodeName)
423409
const externalIP = Templates.renderFullyQualifiedNetworkSvcName(namespace, nodeName)
424410

425-
const account = nodeInfo.accountId
411+
const account = nodeAccountMap.get(nodeID)
426412
if (releaseVersion.minor >= 40) {
427-
configLines.push(`address, ${nodeSeq}, ${nodeNickName}, ${nodeName}, ${nodeStakeAmount}, ${internalIP}, ${internalPort}, ${externalIP}, ${externalPort}, ${account}`)
413+
configLines.push(`address, ${nodeSeq}, ${nodeName}, ${nodeName}, ${nodeStakeAmount}, ${internalIP}, ${internalPort}, ${externalIP}, ${externalPort}, ${account}`)
428414
} else {
429415
configLines.push(`address, ${nodeSeq}, ${nodeName}, ${nodeStakeAmount}, ${internalIP}, ${internalPort}, ${externalIP}, ${externalPort}, ${account}`)
430416
}

0 commit comments

Comments
 (0)