Skip to content

Commit 58e7a44

Browse files
authored
make sure we have enough time to claim (#1298)
1 parent f2c5f53 commit 58e7a44

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

src/components/c2d/compute_engines.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { OceanNodeConfig } from '../../@types/OceanNode.js'
55
import { C2DDatabase } from '../database/C2DDatabase.js'
66
import { Escrow } from '../core/utils/escrow.js'
77
import { KeyManager } from '../KeyManager/index.js'
8+
import { CORE_LOGGER } from '../../utils/logging/common.js'
89

910
export class C2DEngines {
1011
public engines: C2DEngine[]
@@ -24,16 +25,25 @@ export class C2DEngines {
2425
let cpuOffset = 0
2526
for (const cluster of config.c2dClusters) {
2627
if (cluster.type === C2DClusterType.DOCKER) {
27-
this.engines.push(
28-
new C2DEngineDocker(
29-
cluster,
30-
db,
31-
escrow,
32-
keyManager,
33-
config.dockerRegistrysAuth,
34-
cpuOffset
28+
// do some checks
29+
const limit = 6
30+
const claimDurationTimeout = escrow.getMinLockTime(0)
31+
if (cluster.connection.paymentClaimInterval * limit > claimDurationTimeout) {
32+
CORE_LOGGER.error(
33+
`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})`
3534
)
36-
)
35+
} else {
36+
this.engines.push(
37+
new C2DEngineDocker(
38+
cluster,
39+
db,
40+
escrow,
41+
keyManager,
42+
config.dockerRegistrysAuth,
43+
cpuOffset
44+
)
45+
)
46+
}
3747
// Advance the CPU offset by this cluster's configured CPU total
3848
if (cluster.connection?.resources) {
3949
const cpuRes = cluster.connection.resources.find((r: any) => r.id === 'cpu')

0 commit comments

Comments
 (0)