Skip to content

Commit

Permalink
Merge pull request #3150 from OriginTrail/v6/prerelease/testnet
Browse files Browse the repository at this point in the history
OriginTrail Testnet Release v6.3.0.Hotfix 2
  • Loading branch information
djordjekovac authored Apr 23, 2024
2 parents d92297b + 5ab173b commit 0ebf1a7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 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": "6.3.0+hotfix.1",
"version": "6.3.0+hotfix.2",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class BlockchainGetLatestServiceAgreement extends Command {
if (result) {
// eslint-disable-next-line no-param-reassign
command.data[result.contract] = result.lastProcessedTokenId;
this.logger.debug(
`Get latest service agreement: updating last processed token id: ${result.lastProcessedTokenId} for blockchain ${blockchain}`,
);
}
});

Expand Down Expand Up @@ -131,7 +134,7 @@ class BlockchainGetLatestServiceAgreement extends Command {
}
return {
contract,
lastProcessedTokenId: latestDbTokenId,
lastProcessedTokenId: latestBlockchainTokenId,
};
}

Expand All @@ -142,6 +145,12 @@ class BlockchainGetLatestServiceAgreement extends Command {
hashFunctionId = CONTENT_ASSET_HASH_FUNCTION_ID,
) {
try {
if (await this.repositoryModuleManager.serviceAgreementExists(blockchain, tokenId)) {
this.logger.debug(
`Get latest service agreement: data exists in repository for token id: ${tokenId} on blockchain: ${blockchain}`,
);
return;
}
this.logger.debug(
`Get latest service agreement: Getting agreement data for token id: ${tokenId} on blockchain: ${blockchain}`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ class ServiceAgreementRepository {
);
}

async serviceAgreementExists(blockchainId, tokenId) {
const agreementRecord = await this.model.findOne({
where: {
blockchainId,
tokenId,
},
});
return !!agreementRecord;
}

async bulkCreateServiceAgreementRecords(serviceAgreements) {
return this.model.bulkCreate(serviceAgreements, {
ignoreDuplicates: true,
Expand Down
9 changes: 9 additions & 0 deletions src/modules/repository/repository-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ class RepositoryModuleManager extends BaseModuleManager {
}
}

async serviceAgreementExists(blockchain, tokenId) {
if (this.initialized) {
return this.getRepository('service_agreement').serviceAgreementExists(
blockchain,
tokenId,
);
}
}

async bulkCreateServiceAgreementRecords(records) {
if (this.initialized) {
return this.getRepository('service_agreement').bulkCreateServiceAgreementRecords(
Expand Down

0 comments on commit 0ebf1a7

Please sign in to comment.