Skip to content

Commit

Permalink
pushing current code
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
  • Loading branch information
jeromy-cannon committed Nov 22, 2024
1 parent 90dbea9 commit 98a031a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
13 changes: 6 additions & 7 deletions src/commands/node/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import {
DEFAULT_NETWORK_NODE_NAME,
FREEZE_ADMIN_ACCOUNT,
HEDERA_NODE_DEFAULT_STAKE_AMOUNT,
HEDERA_NODE_DEFAULT_STAKE_AMOUNT, IGNORED_NODE_ACCOUNT_ID,
LOCAL_HOST,
SECONDS,
TREASURY_ACCOUNT_ID
Expand Down Expand Up @@ -1176,21 +1176,20 @@ export class NodeCommandTasks {
const nodeId = Templates.nodeIdFromNodeAlias(config.nodeAlias) - 1

let valuesArg = ''
let nodeIndex = 0
for (let i = 0; i < index; i++) {
if (transactionType === NodeSubcommandType.UPDATE && config.newAccountNumber && i === nodeId) { // for the case of updating node
// use new account number for this node id
valuesArg += ` --set "hedera.nodes[${nodeIndex}].accountId=${config.newAccountNumber}" --set "hedera.nodes[${nodeIndex}].name=${config.existingNodeAliases[i]}"`
nodeIndex++
valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.newAccountNumber}" --set "hedera.nodes[${i}].name=${config.existingNodeAliases[i]}"`
} else if (transactionType !== NodeSubcommandType.DELETE || i !== nodeId) { // for the case of deleting node
valuesArg += ` --set "hedera.nodes[${nodeIndex}].accountId=${config.serviceMap.get(config.existingNodeAliases[i]).accountId}" --set "hedera.nodes[${nodeIndex}].name=${config.existingNodeAliases[i]}"`
nodeIndex++
valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeAliases[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeAliases[i]}"`
} else if (transactionType === NodeSubcommandType.DELETE && i === nodeId) {
valuesArg += ` --set "hedera.nodes[${i}].accountId=${IGNORED_NODE_ACCOUNT_ID}" --set "hedera.nodes[${i}].name=${config.existingNodeAliases[i]}"`
}
}

// for the case of adding new node
if (transactionType === NodeSubcommandType.ADD && ctx.newNode && ctx.newNode.accountId) {
valuesArg += ` --set "hedera.nodes[${nodeIndex}].accountId=${ctx.newNode.accountId}" --set "hedera.nodes[${nodeIndex}].name=${ctx.newNode.name}"`
valuesArg += ` --set "hedera.nodes[${index}].accountId=${ctx.newNode.accountId}" --set "hedera.nodes[${index}].name=${ctx.newNode.name}"`
}
const profileValuesFile = await self.profileManager.prepareValuesForNodeAdd(
path.join(config.stagingDir, 'config.txt'),
Expand Down
9 changes: 6 additions & 3 deletions src/core/account_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { type SoloLogger } from './logging.js'
import { type K8 } from './k8.js'
import { type AccountIdWithKeyPairObject, type ExtendedNetServer } from '../types/index.js'
import { type NodeAlias, type PodName } from '../types/aliases.js'
import { IGNORED_NODE_ACCOUNT_ID } from './constants.js'

const REASON_FAILED_TO_GET_KEYS = 'failed to get keys for accountId'
const REASON_SKIPPED = 'skipped since it does not have a genesis key'
Expand Down Expand Up @@ -222,9 +223,11 @@ export class AccountManager {
let localPort = constants.LOCAL_NODE_START_PORT

for (const networkNodeService of networkNodeServicesMap.values()) {
const addlNode = await this.configureNodeAccess(networkNodeService, localPort, networkNodeServicesMap.size)
nodes = { ...nodes, ...addlNode }
localPort++
if (networkNodeService.accountId !== IGNORED_NODE_ACCOUNT_ID) {
const addlNode = await this.configureNodeAccess(networkNodeService, localPort, networkNodeServicesMap.size)
nodes = { ...nodes, ...addlNode }
localPort++
}
}

this.logger.debug(`creating client from network configuration: ${JSON.stringify(nodes)}`)
Expand Down
1 change: 1 addition & 0 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,4 @@ export const RELAY_PODS_READY_DELAY = +process.env.RELAY_PODS_READY_DELAY || 1_0


export const DEFAULT_LOCAL_CONFIG_FILE = 'local-config.yaml'
export const IGNORED_NODE_ACCOUNT_ID = '0.0.0'

0 comments on commit 98a031a

Please sign in to comment.