diff --git a/src/commands/node/tasks.ts b/src/commands/node/tasks.ts index b107d9245..21ef05a73 100644 --- a/src/commands/node/tasks.ts +++ b/src/commands/node/tasks.ts @@ -1090,37 +1090,37 @@ export class NodeCommandTasks { } sendNodeUpdateTransaction () { + const self = this return new Task('Send node update transaction', async (ctx: any, task: ListrTaskWrapper) => { const config: NodeUpdateConfigClass = ctx.config const nodeId = Templates.nodeIdFromNodeAlias(config.nodeAlias) - 1 - this.logger.info(`nodeId: ${nodeId}`) - this.logger.info(`config.newAccountNumber: ${config.newAccountNumber}`) + self.logger.info(`nodeId: ${nodeId}, config.newAccountNumber: ${config.newAccountNumber}`) try { const nodeUpdateTx = new NodeUpdateTransaction().setNodeId(nodeId) if (config.tlsPublicKey && config.tlsPrivateKey) { - this.logger.info(`config.tlsPublicKey: ${config.tlsPublicKey}`) - const tlsCertDer = this._loadPermCertificate(config.tlsPublicKey) + self.logger.info(`config.tlsPublicKey: ${config.tlsPublicKey}`) + const tlsCertDer = self._loadPermCertificate(config.tlsPublicKey) const tlsCertHash = crypto.createHash('sha384').update(tlsCertDer).digest() nodeUpdateTx.setCertificateHash(tlsCertHash) const publicKeyFile = Templates.renderTLSPemPublicKeyFile(config.nodeAlias) const privateKeyFile = Templates.renderTLSPemPrivateKeyFile(config.nodeAlias) - renameAndCopyFile(config.tlsPublicKey, publicKeyFile, config.keysDir, this.logger) - renameAndCopyFile(config.tlsPrivateKey, privateKeyFile, config.keysDir, this.logger) + renameAndCopyFile(config.tlsPublicKey, publicKeyFile, config.keysDir, self.logger) + renameAndCopyFile(config.tlsPrivateKey, privateKeyFile, config.keysDir, self.logger) } if (config.gossipPublicKey && config.gossipPrivateKey) { - this.logger.info(`config.gossipPublicKey: ${config.gossipPublicKey}`) - const signingCertDer = this._loadPermCertificate(config.gossipPublicKey) + self.logger.info(`config.gossipPublicKey: ${config.gossipPublicKey}`) + const signingCertDer = self._loadPermCertificate(config.gossipPublicKey) nodeUpdateTx.setGossipCaCertificate(signingCertDer) const publicKeyFile = Templates.renderGossipPemPublicKeyFile(config.nodeAlias) const privateKeyFile = Templates.renderGossipPemPrivateKeyFile(config.nodeAlias) - renameAndCopyFile(config.gossipPublicKey, publicKeyFile, config.keysDir, this.logger) - renameAndCopyFile(config.gossipPrivateKey, privateKeyFile, config.keysDir, this.logger) + renameAndCopyFile(config.gossipPublicKey, publicKeyFile, config.keysDir, self.logger) + renameAndCopyFile(config.gossipPrivateKey, privateKeyFile, config.keysDir, self.logger) } if (config.newAccountNumber) { @@ -1141,10 +1141,11 @@ export class NodeCommandTasks { const signedTx = await nodeUpdateTx.sign(config.adminKey) const txResp = await signedTx.execute(config.nodeClient) const nodeUpdateReceipt = await txResp.getReceipt(config.nodeClient) - this.logger.debug(`NodeUpdateReceipt: ${nodeUpdateReceipt.toString()}`) + self.logger.debug(`NodeUpdateReceipt: ${nodeUpdateReceipt.toString()}`) + await self.accountManager.refreshNodeClient(config.namespace, config.nodeAlias) } catch (e) { - this.logger.error(`Error updating node to network: ${e.message}`, e) - this.logger.error(e.stack) + self.logger.error(`Error updating node to network: ${e.message}`, e) + self.logger.error(e.stack) throw new SoloError(`Error updating node to network: ${e.message}`, e) } }) diff --git a/src/core/account_manager.ts b/src/core/account_manager.ts index fd14bf7f3..a3e3c5004 100644 --- a/src/core/account_manager.ts +++ b/src/core/account_manager.ts @@ -164,14 +164,15 @@ export class AccountManager { /** * loads and initializes the Node Client * @param namespace - the namespace of the network + * @param skipNodeAlias - the node alias to skip */ - async refreshNodeClient (namespace: string) { + async refreshNodeClient (namespace: string, skipNodeAlias? : NodeAlias) { await this.close() const treasuryAccountInfo = await this.getTreasuryAccountKeys(namespace) const networkNodeServicesMap = await this.getNodeServiceMap(namespace) this._nodeClient = await this._getNodeClient(namespace, - networkNodeServicesMap, treasuryAccountInfo.accountId, treasuryAccountInfo.privateKey) + networkNodeServicesMap, treasuryAccountInfo.accountId, treasuryAccountInfo.privateKey, skipNodeAlias) } /** @@ -216,14 +217,13 @@ export class AccountManager { * @param operatorKey - the private key of the operator of the transactions * @returns a node client that can be used to call transactions */ - async _getNodeClient (namespace: string, networkNodeServicesMap: Map, operatorId: string, - operatorKey: string) { + async _getNodeClient (namespace: string, networkNodeServicesMap: Map, operatorId: string, operatorKey: string, skipNodeAlias: string) { let nodes = {} try { let localPort = constants.LOCAL_NODE_START_PORT for (const networkNodeService of networkNodeServicesMap.values()) { - if (networkNodeService.accountId !== IGNORED_NODE_ACCOUNT_ID) { + if (networkNodeService.accountId !== IGNORED_NODE_ACCOUNT_ID && networkNodeService.nodeAlias !== skipNodeAlias) { const addlNode = await this.configureNodeAccess(networkNodeService, localPort, networkNodeServicesMap.size) nodes = { ...nodes, ...addlNode } localPort++