@@ -33,7 +33,7 @@ import { FindDdoHandler } from '../handler/ddoHandler.js'
3333import { isOrderingAllowedForAsset } from '../handler/downloadHandler.js'
3434import { DDOManager } from '@oceanprotocol/ddo-js'
3535import { getNonceAsNumber , checkNonce , NonceResponse } from '../utils/nonceHandler.js'
36- import { createHash } from 'crypto '
36+ import { generateUniqueID } from '../../database/sqliteCompute.js '
3737
3838export class PaidComputeStartHandler extends CommandHandler {
3939 validate ( command : PaidComputeStartCommand ) : ValidateParams {
@@ -353,12 +353,7 @@ export class PaidComputeStartHandler extends CommandHandler {
353353 resources
354354 }
355355 // job ID unicity
356- const timestamp =
357- BigInt ( Date . now ( ) ) * 1_000_000n + ( process . hrtime . bigint ( ) % 1_000_000n )
358- const random = Math . random ( )
359- const jobId = createHash ( 'sha256' )
360- . update ( JSON . stringify ( s ) + timestamp . toString ( ) + random . toString ( ) )
361- . digest ( 'hex' )
356+ const jobId = generateUniqueID ( s )
362357 // let's calculate payment needed based on resources request and maxJobDuration
363358 const cost = engine . calculateResourcesCost (
364359 task . payment . resources ,
@@ -400,7 +395,8 @@ export class PaidComputeStartHandler extends CommandHandler {
400395 token : task . payment . token ,
401396 lockTx : agreementId ,
402397 claimTx : null
403- }
398+ } ,
399+ jobId
404400 )
405401 CORE_LOGGER . logMessage (
406402 'ComputeStartCommand Response: ' + JSON . stringify ( response , null , 2 ) ,
@@ -561,6 +557,16 @@ export class FreeComputeStartHandler extends CommandHandler {
561557 error: null
562558 }
563559 } */
560+ const s = {
561+ assets : task . datasets ,
562+ algorithm : task . algorithm ,
563+ output : task . output ,
564+ environment : task . environment ,
565+ owner : task . consumerAddress ,
566+ maxJobDuration : task . maxJobDuration ,
567+ resources : task . resources
568+ }
569+ const jobId = generateUniqueID ( s )
564570 const response = await engine . startComputeJob (
565571 task . datasets ,
566572 task . algorithm ,
@@ -569,7 +575,8 @@ export class FreeComputeStartHandler extends CommandHandler {
569575 task . consumerAddress ,
570576 task . maxJobDuration ,
571577 task . resources ,
572- null
578+ null ,
579+ jobId
573580 )
574581
575582 CORE_LOGGER . logMessage (
0 commit comments