Skip to content

Commit

Permalink
ignore conflicts instead of using save
Browse files Browse the repository at this point in the history
  • Loading branch information
oXtxNt9U committed Oct 27, 2023
1 parent 53f0f34 commit 1b0170e
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions packages/api-sync/source/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ export class Sync implements Contracts.ApiSync.ISync {

...(Utils.roundCalculator.isNewRound(header.height, this.configuration)
? {
validatorRound: {
round,
roundHeight,
validators: this.validatorSet
.getActiveValidators()
.map((validator) => validator.getWalletPublicKey()),
},
}
validatorRound: {
round,
roundHeight,
validators: this.validatorSet
.getActiveValidators()
.map((validator) => validator.getWalletPublicKey()),
},
}
: {}),
};

Expand Down Expand Up @@ -252,7 +252,12 @@ export class Sync implements Contracts.ApiSync.ISync {
const validatorRoundRepository = this.validatorRoundRepositoryFactory(entityManager);
const walletRepository = this.walletRepositoryFactory(entityManager);

await blockRepository.save(deferred.block);
await blockRepository
.createQueryBuilder()
.insert()
.orIgnore()
.values(deferred.block)
.execute();

await stateRepository
.createQueryBuilder()
Expand All @@ -268,7 +273,12 @@ export class Sync implements Contracts.ApiSync.ISync {
})
.execute();

await transactionRepository.save(deferred.transactions);
await transactionRepository
.createQueryBuilder()
.insert()
.orIgnore()
.values(deferred.transactions)
.execute();

if (deferred.validatorRound) {
await validatorRoundRepository
Expand Down

0 comments on commit 1b0170e

Please sign in to comment.