Skip to content

Commit

Permalink
chore: ensure staking updates support multi-cluster deployments
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Klick <[email protected]>
  • Loading branch information
nathanklick committed Feb 17, 2025
1 parent 269a0ef commit 1d0bdf9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/commands/node/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ export class NodeCommandTasks {
accountId: string,
nodeAlias: NodeAlias,
stakeAmount: number = HEDERA_NODE_DEFAULT_STAKE_AMOUNT,
context?: string,
) {
try {
const deploymentName = this.configManager.getFlag<DeploymentName>(flags.deployment);
Expand All @@ -573,6 +574,7 @@ export class NodeCommandTasks {
this.parent.getClusterRefs(),
deploymentName,
this.configManager.getFlag<boolean>(flags.forcePortForward),
context,
);
const client = this.accountManager._nodeClient;
const treasuryKey = await this.accountManager.getTreasuryAccountKeys(namespace);
Expand Down Expand Up @@ -1274,11 +1276,12 @@ export class NodeCommandTasks {
let nodeIndex = 0;
for (const nodeAlias of ctx.config.nodeAliases) {
const accountId = accountMap.get(nodeAlias);
const context = helpers.extractContextFromConsensusNodes(nodeAlias, ctx.config.consensusNodes);
const stakeAmount =
stakeAmountParsed.length > 0 ? stakeAmountParsed[nodeIndex] : HEDERA_NODE_DEFAULT_STAKE_AMOUNT;
subTasks.push({
title: `Adding stake for node: ${chalk.yellow(nodeAlias)}`,
task: async () => await self._addStake(ctx.config.namespace, accountId, nodeAlias, +stakeAmount),
task: async () => await self._addStake(ctx.config.namespace, accountId, nodeAlias, +stakeAmount, context),
});
nodeIndex++;
}
Expand All @@ -1297,13 +1300,16 @@ export class NodeCommandTasks {
stakeNewNode() {
const self = this;
return new Task('Stake new node', async (ctx: any, task: ListrTaskWrapper<any, any, any>) => {
const context = helpers.extractContextFromConsensusNodes(ctx.config.nodeAlias, ctx.config.consensusNodes);
await self.accountManager.refreshNodeClient(
ctx.config.namespace,
ctx.config.nodeAlias,
this.parent.getClusterRefs(),
this.configManager.getFlag<DeploymentName>(flags.deployment),
context,
this.configManager.getFlag<boolean>(flags.forcePortForward),
);
await this._addStake(ctx.config.namespace, ctx.newNode.accountId, ctx.config.nodeAlias);
await this._addStake(ctx.config.namespace, ctx.newNode.accountId, ctx.config.nodeAlias, undefined, context);
});
}

Expand Down

0 comments on commit 1d0bdf9

Please sign in to comment.