Skip to content

Commit

Permalink
fix: update to AccountManager._getNodeClient() to parallel node conne…
Browse files Browse the repository at this point in the history
…ction setup (#1091)

Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
  • Loading branch information
jeromy-cannon authored Jan 2, 2025
1 parent 84e6611 commit 4959a12
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/core/account_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ export class AccountManager {
skipNodeAlias: string,
) {
let nodes = {};
const configureNodeAccessPromiseArray = [];

try {
let localPort = constants.LOCAL_NODE_START_PORT;

Expand All @@ -230,12 +232,25 @@ export class AccountManager {
networkNodeService.accountId !== IGNORED_NODE_ACCOUNT_ID &&
networkNodeService.nodeAlias !== skipNodeAlias
) {
const addlNode = await this.configureNodeAccess(networkNodeService, localPort, networkNodeServicesMap.size);
nodes = {...nodes, ...addlNode};
configureNodeAccessPromiseArray.push(
this.configureNodeAccess(networkNodeService, localPort, networkNodeServicesMap.size),
);
localPort++;
}
}

await Promise.allSettled(configureNodeAccessPromiseArray).then(results => {
for (const result of results) {
switch (result.status) {
case REJECTED:
throw new SoloError(`failed to configure node access: ${result.reason}`);
case FULFILLED:
nodes = {...nodes, ...result.value};
break;
}
}
});

let formattedNetworkConnection = '';
Object.keys(nodes).forEach(key => (formattedNetworkConnection += `${key}:${nodes[key]}, `));
this.logger.debug(`creating client from network configuration: [${formattedNetworkConnection}]`);
Expand Down
4 changes: 2 additions & 2 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ export const NODE_CLIENT_MIN_BACKOFF = +process.env.NODE_CLIENT_MIN_BACKOFF || 1
export const NODE_CLIENT_MAX_BACKOFF = +process.env.NODE_CLIENT_MAX_BACKOFF || 1_000;
export const NODE_CLIENT_REQUEST_TIMEOUT = +process.env.NODE_CLIENT_REQUEST_TIMEOUT || 600_000;
export const NODE_CLIENT_PING_INTERVAL = +process.env.NODE_CLIENT_PING_INTERVAL || 30_000;
export const NODE_CLIENT_PING_MAX_RETRIES = +process.env.NODE_CLIENT_PING_MAX_RETRIES || 10;
export const NODE_CLIENT_PING_RETRY_INTERVAL = +process.env.NODE_CLIENT_PING_RETRY_INTERVAL || 30_000;
export const NODE_CLIENT_PING_MAX_RETRIES = +process.env.NODE_CLIENT_PING_MAX_RETRIES || 5;
export const NODE_CLIENT_PING_RETRY_INTERVAL = +process.env.NODE_CLIENT_PING_RETRY_INTERVAL || 10_000;

// ---- New Node Related ----
export const ENDPOINT_TYPE_IP = 'IP';
Expand Down

0 comments on commit 4959a12

Please sign in to comment.