Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function divider() {
epochsNum: 2,
minimumNumberOfFinalizationConfirmations: 3,
minimumNumberOfNodeReplications: 1,
localStore: true,
Comment thread
Mihajlo-Pavlovic marked this conversation as resolved.
});
console.timeEnd('Publish (1 replication, 3 finalizations)');

Expand Down
19 changes: 19 additions & 0 deletions managers/asset-operations-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default class AssetOperationsManager {
payer,
minimumNumberOfFinalizationConfirmations,
minimumNumberOfNodeReplications,
localStore,
} = this.inputService.getAssetCreateArguments(options);

this.validationService.validateAssetCreate(
Expand Down Expand Up @@ -470,6 +471,23 @@ export default class AssetOperationsManager {
frequency,
);
}
let localStoreResult;
if (localStore) {
let retry = 0;
do {
// eslint-disable-next-line no-await-in-loop
localStoreResult = await this.nodeApiService.localStore(
endpoint,
port,
authToken,
datasetRoot,
dataset,
blockchain.name,
UAL,
);
retry += 1;
} while (!localStoreResult?.status && retry < 6);
Comment thread
Mihajlo-Pavlovic marked this conversation as resolved.
}

return {
UAL,
Expand All @@ -486,6 +504,7 @@ export default class AssetOperationsManager {
},
numberOfConfirmations: finalityStatusResult,
requiredConfirmations: minimumNumberOfFinalizationConfirmations,
...(localStore && { localStore: localStoreResult }),
},
};
}
Expand Down
5 changes: 5 additions & 0 deletions services/input-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class InputService {
minimumNumberOfFinalizationConfirmations:
this.getMinimumNumberOfFinalizationConfirmations(options) ?? 3,
minimumNumberOfNodeReplications: this.getMinimumNumberOfNodeReplications(options),
localStore: this.getLocalStore(options),
};
}

Expand Down Expand Up @@ -415,4 +416,8 @@ export default class InputService {
getAssertionCachedLocally(options) {
return options.assertionCachedLocally ?? false;
}

getLocalStore(options) {
return options.localStore ?? false;
}
}
20 changes: 20 additions & 0 deletions services/node-api-service/implementations/http-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ export default class HttpService {
}
}

async localStore(endpoint, port, authToken, datasetRoot, dataset, blockchain, UAL) {
try {
const response = await axios({
method: 'post',
url: `${this.getBaseUrl(endpoint, port)}/local-store`,
data: {
datasetRoot,
dataset,
blockchain,
UAL,
},
headers: this.prepareRequestConfig(authToken),
});

return response.data;
} catch (error) {
throw Error(`Unable to local store: ${error.message}`);
}
}

async get(
endpoint,
port,
Expand Down