Skip to content

Commit

Permalink
Execute first replication and after store locally (#127)
Browse files Browse the repository at this point in the history
* Change order: first replicate if it succeeds, store locally

* Bump version to 6.1.2
  • Loading branch information
NZT48 authored Jan 12, 2024
1 parent 5762027 commit a9d150b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dist/dkg.min.js

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions managers/asset-operations-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,24 +366,31 @@ class AssetOperationsManager {
storeType: STORE_TYPES.TRIPLE,
});
}
let operationId = await this.nodeApiService.localStore(

const UAL = deriveUAL(blockchain.name, contentAssetStorageAddress, tokenId);

let operationId = await this.nodeApiService.publish(
endpoint,
port,
authToken,
assertions,
publicAssertionId,
publicAssertion,
blockchain.name,
contentAssetStorageAddress,
tokenId,
hashFunctionId,
);

let operationResult = await this.nodeApiService.getOperationResult(
endpoint,
port,
authToken,
OPERATIONS.LOCAL_STORE,
OPERATIONS.PUBLISH,
maxNumberOfRetries,
DEFAULT_GET_LOCAL_STORE_RESULT_FREQUENCY,
frequency,
operationId,
);

const UAL = deriveUAL(blockchain.name, contentAssetStorageAddress, tokenId);

if (operationResult.status === OPERATION_STATUSES.FAILED) {
return {
UAL,
Expand All @@ -392,25 +399,20 @@ class AssetOperationsManager {
};
}

operationId = await this.nodeApiService.publish(
operationId = await this.nodeApiService.localStore(
endpoint,
port,
authToken,
publicAssertionId,
publicAssertion,
blockchain.name,
contentAssetStorageAddress,
tokenId,
hashFunctionId,
assertions,
);

operationResult = await this.nodeApiService.getOperationResult(
endpoint,
port,
authToken,
OPERATIONS.PUBLISH,
OPERATIONS.LOCAL_STORE,
maxNumberOfRetries,
frequency,
DEFAULT_GET_LOCAL_STORE_RESULT_FREQUENCY,
operationId,
);

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dkg.js",
"version": "6.1.1",
"version": "6.1.2",
"description": "Javascript library for interaction with the OriginTrail Decentralized Knowledge Graph",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a9d150b

Please sign in to comment.