From f191cc7258f362f95ddcb6d8bfbd555272cca69d Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Thu, 26 Mar 2026 16:51:35 +0200 Subject: [PATCH] make sure we have enough time to claim --- src/components/c2d/compute_engines.ts | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/c2d/compute_engines.ts b/src/components/c2d/compute_engines.ts index 4934d9416..ca3ca55d0 100644 --- a/src/components/c2d/compute_engines.ts +++ b/src/components/c2d/compute_engines.ts @@ -5,6 +5,7 @@ import { OceanNodeConfig } from '../../@types/OceanNode.js' import { C2DDatabase } from '../database/C2DDatabase.js' import { Escrow } from '../core/utils/escrow.js' import { KeyManager } from '../KeyManager/index.js' +import { CORE_LOGGER } from '../../utils/logging/common.js' export class C2DEngines { public engines: C2DEngine[] @@ -24,16 +25,25 @@ export class C2DEngines { let cpuOffset = 0 for (const cluster of config.c2dClusters) { if (cluster.type === C2DClusterType.DOCKER) { - this.engines.push( - new C2DEngineDocker( - cluster, - db, - escrow, - keyManager, - config.dockerRegistrysAuth, - cpuOffset + // do some checks + const limit = 6 + const claimDurationTimeout = escrow.getMinLockTime(0) + if (cluster.connection.paymentClaimInterval * limit > claimDurationTimeout) { + CORE_LOGGER.error( + `Cannot create engine ${cluster.connection.hash}.\r\nConfig.claimDurationTimeout is not high enough to claim at least ${limit} times. Either decrease environment.paymentClaimInterval${cluster.connection.paymentClaimInterval} or increase config.claimDurationTimeout(${claimDurationTimeout})` ) - ) + } else { + this.engines.push( + new C2DEngineDocker( + cluster, + db, + escrow, + keyManager, + config.dockerRegistrysAuth, + cpuOffset + ) + ) + } // Advance the CPU offset by this cluster's configured CPU total if (cluster.connection?.resources) { const cpuRes = cluster.connection.resources.find((r: any) => r.id === 'cpu')