Skip to content

Commit

Permalink
Merge pull request #508 from oceanprotocol/issue-506-agreementid-stop
Browse files Browse the repository at this point in the history
Issue 506 agreementid stop
  • Loading branch information
alexcos20 authored Aug 14, 2024
2 parents 9319b6f + cddadc1 commit 3887055
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/@types/C2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export interface OPFK8ComputeStart {
export interface OPFK8ComputeStop {
jobId: string
owner: string
agreementId?: string
providerSignature: string // message=owner+jobId
providerAddress: string
nonce: number
Expand Down
1 change: 1 addition & 0 deletions src/@types/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export interface ComputeStopCommand extends Command {
signature: string
nonce: string
jobId: string
agreementId?: string
}

export interface ComputeGetResultCommand extends Command {
Expand Down
6 changes: 4 additions & 2 deletions src/components/c2d/compute_engines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ export class C2DEngineOPFK8 extends C2DEngine {

public override async stopComputeJob(
jobId: string,
owner: string
owner: string,
agreementId?: string
): Promise<ComputeJob[]> {
// and the full payload
const nonce: number = new Date().getTime()
Expand All @@ -303,7 +304,8 @@ export class C2DEngineOPFK8 extends C2DEngine {
providerSignature,
providerAddress: config.keys.ethAddress,
nonce,
jobId
jobId,
agreementId
}
try {
const response = await axios({
Expand Down
8 changes: 7 additions & 1 deletion src/components/core/compute/stopCompute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class ComputeStopHandler extends Handler {
const index = task.jobId.indexOf('-')
const hash = task.jobId.slice(0, index)
const jobId = task.jobId.slice(index + 1)
// eslint-disable-next-line prefer-destructuring
const agreementId = task.agreementId

// env might contain
let engine
Expand All @@ -54,7 +56,11 @@ export class ComputeStopHandler extends Handler {
}
}
}
const response = await engine.stopComputeJob(jobId, task.consumerAddress)
const response = await engine.stopComputeJob(
jobId,
task.consumerAddress,
agreementId
)

CORE_LOGGER.logMessage(
'StopComputeCommand Response: ' + JSON.stringify(response, null, 2),
Expand Down
11 changes: 6 additions & 5 deletions src/components/httpRoutes/compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ computeRoutes.put(`${SERVICES_API_BASE_PATH}/compute`, async (req, res) => {

const stopComputeTask: ComputeStopCommand = {
command: PROTOCOL_COMMANDS.COMPUTE_STOP,
node: (req.body.node as string) || null,
consumerAddress: (req.body.consumerAddress as string) || null,
signature: (req.body.signature as string) || null,
nonce: (req.body.nonce as string) || null,
jobId: (req.body.jobId as string) || null
node: (req.query.node as string) || null,
consumerAddress: (req.query.consumerAddress as string) || null,
signature: (req.query.signature as string) || null,
nonce: (req.query.nonce as string) || null,
jobId: (req.query.jobId as string) || null,
agreementId: (req.query.agreementId as string) || null
}
const response = await new ComputeStopHandler(req.oceanNode).handle(stopComputeTask)
const jobs = await streamToObject(response.stream as Readable)
Expand Down

0 comments on commit 3887055

Please sign in to comment.