diff --git a/src/@types/C2D/C2D.ts b/src/@types/C2D/C2D.ts index c237cab10..f6cdb9ed6 100644 --- a/src/@types/C2D/C2D.ts +++ b/src/@types/C2D/C2D.ts @@ -213,6 +213,7 @@ export interface ComputeAlgorithm { export interface AlgoChecksums { files: string container: string + serviceId?: string } export interface DBComputeJobPayment { diff --git a/src/components/core/compute/utils.ts b/src/components/core/compute/utils.ts index bfbfd43ac..f9b5cac80 100644 --- a/src/components/core/compute/utils.ts +++ b/src/components/core/compute/utils.ts @@ -31,7 +31,8 @@ export async function getAlgoChecksums( ): Promise { const checksums: AlgoChecksums = { files: '', - container: '' + container: '', + serviceId: algoServiceId } try { const algoDDO = await new FindDdoHandler(oceanNode).findAndFormatDdo(algoDID) @@ -76,6 +77,7 @@ export async function validateAlgoForDataset( algoChecksums: { files: string container: string + serviceId?: string }, ddoInstance: VersionedDDO, datasetServiceId: string, @@ -115,6 +117,12 @@ export async function validateAlgoForDataset( const containerMatch = algo.containerSectionChecksum === '*' || algo.containerSectionChecksum === algoChecksums.container + if ('serviceId' in Object.keys(algo)) { + const serviceIdMatch = + algo.serviceId === '*' || algo.serviceId === algoChecksums.serviceId + return didMatch && filesMatch && containerMatch && serviceIdMatch + } + return didMatch && filesMatch && containerMatch }) diff --git a/src/test/integration/compute.test.ts b/src/test/integration/compute.test.ts index 487fe1e0b..bb5d441bf 100644 --- a/src/test/integration/compute.test.ts +++ b/src/test/integration/compute.test.ts @@ -1256,6 +1256,7 @@ describe('Compute', () => { expect(algoChecksums.container).to.equal( 'ba8885fcc7d366f058d6c3bb0b7bfe191c5f85cb6a4ee3858895342436c23504' ) + expect(algoChecksums.serviceId).to.equal(algoDDOTest.services[0].id) } else expect(expectedTimeoutFailure(this.test.title)).to.be.equal(wasTimeout) })