From dec6c35319f52c8b542375f0a2ed5930c1509dc3 Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Sat, 1 Feb 2020 20:59:50 +0200 Subject: [PATCH] updated checkoutput --- src/ocean/OceanCompute.ts | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/ocean/OceanCompute.ts b/src/ocean/OceanCompute.ts index 6c91ebc..7b7aabc 100644 --- a/src/ocean/OceanCompute.ts +++ b/src/ocean/OceanCompute.ts @@ -105,23 +105,29 @@ export class OceanCompute extends Instantiable { * @param {Object} output Output section used for publishing the result. * @return {Promise} Returns output object */ - public async checkoutput(consumerAccount: Account, output?: Output): Promise { - if (!output) { - // build a minimal object and return it - return this.getminimaloutput() + private checkOutput(consumerAccount: Account, output?: Output): Output { + const isDefault = + !output || (!output.publishAlgorithmLog && !output.publishOutput) + + if (isDefault) { + return { + publishAlgorithmLog: false, + publishOutput: false + } } - if (!output.publishAlgorithmLog && !output.publishOutput) { - return this.getminimaloutput() + + return { + publishAlgorithmLog: output.publishAlgorithmLog, + publishOutput: output.publishOutput, + brizoAddress: output.brizoAddress || this.config.brizoAddress, + brizoUri: output.brizoUri || this.config.brizoUri, + metadataUri: output.metadataUri || this.config.aquariusUri, + nodeUri: output.nodeUri || this.config.nodeUri, + owner: output.owner || consumerAccount.getId(), + secretStoreUri: output.secretStoreUri || this.config.secretStoreUri } - if (!output.brizoAddress) output.brizoAddress = this.config.brizoAddress - if (!output.brizoUri) output.brizoUri = this.config.brizoUri - if (!output.metadataUri) output.metadataUri = this.config.aquariusUri - if (!output.nodeUri) output.nodeUri = this.config.nodeUri - if (!output.owner) output.owner = consumerAccount.getId() - if (!output.secretStoreUri) output.secretStoreUri = this.config.secretStoreUri - return output } - + /** * Start the execution of a compute job. * @param {Account} consumerAccount The account of the consumer ordering the service. @@ -138,7 +144,7 @@ export class OceanCompute extends Instantiable { algorithmMeta?: MetaData, output?: Output ): Promise { - output = await this.checkoutput(consumerAccount, output) + output = this.checkoutput(consumerAccount, output) const status = await this.ocean.brizo.compute( 'post', agreementId,