Skip to content

Commit

Permalink
Add await to calculate root (#3416)
Browse files Browse the repository at this point in the history
* Add await

* version bump
  • Loading branch information
Mihajlo-Pavlovic authored Nov 18, 2024
1 parent 090e93a commit 2884d02
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
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": "origintrail_node",
"version": "8.1.3+beta.0",
"version": "8.1.3+beta.1",
"description": "OTNode V8",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/common/validate-asset-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ValidateAssetCommand extends Command {
);

try {
this.validationService.validateAssertionId(
await this.validationService.validateAssertionId(
cachedData.private.assertion,
cachedData.private.assertionId,
);
Expand Down
2 changes: 1 addition & 1 deletion src/migration/pending-storage-migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PendingStorageMigration extends BaseMigration {
const cachedData = await this.fileService.readFile(newDirectoryPath, true);
await this.fileService.removeFile(newDirectoryPath);
if (cachedData?.public?.assertion) {
const newDocumentName = calculateRoot(cachedData.public.assertion);
const newDocumentName = await calculateRoot(cachedData.public.assertion);
await this.fileService.writeContentsToFile(
newDirectoryPath,
newDocumentName,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/validation/implementation/merkle-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MerkleValidation {
};
}

calculateRoot(assertion) {
async calculateRoot(assertion) {
return calculateRoot(assertion);
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/validation/validation-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ValidationModuleManager extends BaseModuleManager {
return 'validation';
}

calculateRoot(assertion) {
async calculateRoot(assertion) {
if (this.initialized) {
if (!assertion) {
throw new Error('Calculation failed: Assertion cannot be null or undefined.');
Expand Down
6 changes: 3 additions & 3 deletions src/service/validation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ValidationService {
async validateAssertion(assertionId, blockchain, assertion) {
this.logger.info(`Validating assertionId: ${assertionId}`);

this.validateAssertionId(assertion, assertionId);
await this.validateAssertionId(assertion, assertionId);
const blockchainAssertionData = await this.blockchainModuleManager.getAssertionData(
blockchain,
assertionId,
Expand Down Expand Up @@ -80,8 +80,8 @@ class ValidationService {
}
}

validateAssertionId(assertion, assertionId) {
const calculatedAssertionId = this.validationModuleManager.calculateRoot(assertion);
async validateAssertionId(assertion, assertionId) {
const calculatedAssertionId = await this.validationModuleManager.calculateRoot(assertion);

if (assertionId !== calculatedAssertionId) {
// todo after corrective component is implemented, update this logic
Expand Down

0 comments on commit 2884d02

Please sign in to comment.