@@ -214,25 +214,19 @@ export class AccountManager {
214
214
* @returns a node client that can be used to call transactions
215
215
*/
216
216
async _getNodeClient ( namespace : string , networkNodeServicesMap : Map < string , NetworkNodeServices > , operatorId : string ,
217
- operatorKey : string ) {
218
- const nodes = { }
217
+ operatorKey : string , useFirstNodeOnly = true ) {
218
+ let nodes = { }
219
219
try {
220
220
let localPort = constants . LOCAL_NODE_START_PORT
221
221
222
222
for ( const networkNodeService of networkNodeServicesMap . values ( ) ) {
223
- const usePortForward = this . shouldUseLocalHostPortForward ( networkNodeService )
224
- const host = usePortForward ? '127.0.0.1' : networkNodeService . haProxyLoadBalancerIp as string
225
- const port = + networkNodeService . haProxyGrpcPort
226
- const targetPort = usePortForward ? localPort : port
223
+ const addlNode = await this . configureNodeAccess ( networkNodeService , localPort , networkNodeServicesMap . size )
224
+ nodes = { ...nodes , ...addlNode }
225
+ localPort ++
227
226
228
- if ( usePortForward && this . _portForwards . length < networkNodeServicesMap . size ) {
229
- this . _portForwards . push ( await this . k8 . portForward ( networkNodeService . haProxyPodName , localPort , port ) )
227
+ if ( useFirstNodeOnly ) {
228
+ break
230
229
}
231
-
232
- // @ts -ignore
233
- nodes [ `${ host } :${ targetPort } ` ] = AccountId . fromString ( ( networkNodeService . accountId as string ) )
234
- await this . k8 . testConnection ( host , targetPort )
235
- localPort ++
236
230
}
237
231
238
232
this . logger . debug ( `creating client from network configuration: ${ JSON . stringify ( nodes ) } ` )
@@ -250,6 +244,23 @@ export class AccountManager {
250
244
}
251
245
}
252
246
247
+ private async configureNodeAccess ( networkNodeService : NetworkNodeServices , localPort : number , totalNodes : number ) {
248
+ const obj = { }
249
+ const usePortForward = this . shouldUseLocalHostPortForward ( networkNodeService )
250
+ const host = usePortForward ? '127.0.0.1' : networkNodeService . haProxyLoadBalancerIp as string
251
+ const port = + networkNodeService . haProxyGrpcPort
252
+ const targetPort = usePortForward ? localPort : port
253
+
254
+ if ( usePortForward && this . _portForwards . length < totalNodes ) {
255
+ this . _portForwards . push ( await this . k8 . portForward ( networkNodeService . haProxyPodName , localPort , port ) )
256
+ }
257
+
258
+ await this . k8 . testConnection ( host , targetPort )
259
+ obj [ `${ host } :${ targetPort } ` ] = AccountId . fromString ( ( networkNodeService . accountId as string ) )
260
+
261
+ return obj
262
+ }
263
+
253
264
/**
254
265
* Gets a Map of the Hedera node services and the attributes needed
255
266
* @param namespace - the namespace of the solo network deployment
0 commit comments