Skip to content

Commit

Permalink
only increment ports after 1st node package, fixed lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
corn-potage committed May 21, 2024
1 parent b99ab33 commit 15effe4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/main/podman/podman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,14 @@ export const startPodmanNode = async (node: Node): Promise<string[]> => {
}
}

let updatedNode = { ...node };
if (node.runtime?.initialized !== true) {
node = assignPortsToNode(node);
node.runtime.initialized = true;
storeUpdateNode(node);
updatedNode = assignPortsToNode(updatedNode);
updatedNode.runtime.initialized = true;
storeUpdateNode(updatedNode);
}

const podmanCommand = createRunCommand(node);
const podmanCommand = createRunCommand(updatedNode);
// todo: test if input is empty string
const runData = await runCommand(podmanCommand);
// todoo: get containerId by container name?
Expand Down
12 changes: 7 additions & 5 deletions src/main/ports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { httpGet } from './httpReq';
import { getNodePackageByServiceNodeId } from './state/nodePackages';
import { getNode, getNodes, getSetPortHasChanged } from './state/nodes';
import { addNotification } from './state/notifications';
import { getNodePackages } from './state/nodePackages';

export const getPodmanPortsForNode = (
node: Node,
Expand Down Expand Up @@ -120,6 +121,8 @@ export const assignPortsToNode = (node: Node): Node => {
)?.services.find((service) => {
return service.serviceId === 'executionClient';
});

const nodePackages = getNodePackages();
// Update ports using array methods
portTypes.forEach((portType) => {
const defaultPort =
Expand All @@ -137,7 +140,10 @@ export const assignPortsToNode = (node: Node): Node => {
);

// Find next available port if the current/default one is in use
if (usedPorts.includes(assignedPort.toString())) {
if (
nodePackages.length > 1 &&
usedPorts.includes(assignedPort.toString())
) {
assignedPort = Number.parseInt(
findNextAvailablePort(usedPorts, assignedPort),
10,
Expand All @@ -153,10 +159,6 @@ export const assignPortsToNode = (node: Node): Node => {
if (node.spec.rpcTranslation === 'eth-l1-beacon' && executionService) {
const executionNode = getNode(executionService.node.id);
let executionEndpoint = node.config.configValuesMap.executionEndpoint;
console.log(
'enginePortTest',
executionNode.config.configValuesMap.enginePort,
);

// Check if the endpoint is enclosed in quotes
const isQuoted =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ const NodeSettingsWrapper = ({
let isWalletSettingsEnabled = false;
console.log(selectedNode);
if (selectedNode) {
isDisabled = ['running', 'starting'].includes(selectedNode.status);
isDisabled = ['updating', 'running', 'starting'].includes(
selectedNode.status,
);
configTranslationMap = selectedNode.spec.configTranslation;
isWalletSettingsEnabled =
selectedNode.spec.category === 'L1/ExecutionClient';
Expand Down

0 comments on commit 15effe4

Please sign in to comment.