diff --git a/package-lock.json b/package-lock.json index 7d1bc7066..611b263c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.0.9", + "version": "6.0.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.0.9", + "version": "6.0.10", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index 9a9ee6a17..c2d531f07 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.0.9", + "version": "6.0.10", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/modules/repository/implementation/sequelize/repositories/shard-repository.js b/src/modules/repository/implementation/sequelize/repositories/shard-repository.js index 82fbefd1c..3b5afb1d6 100644 --- a/src/modules/repository/implementation/sequelize/repositories/shard-repository.js +++ b/src/modules/repository/implementation/sequelize/repositories/shard-repository.js @@ -126,8 +126,13 @@ class ShardRepository { ); } - async removePeerRecords(peerRecords) { - await this.model.bulkDestroy(peerRecords); + async removePeerRecord(blockchainId, peerId) { + await this.model.destroy({ + where: { + blockchainId, + peerId, + }, + }); } async cleanShardingTable(blockchainId) { diff --git a/src/modules/repository/repository-module-manager.js b/src/modules/repository/repository-module-manager.js index ffef9958e..688cebe9d 100644 --- a/src/modules/repository/repository-module-manager.js +++ b/src/modules/repository/repository-module-manager.js @@ -152,8 +152,8 @@ class RepositoryModuleManager extends BaseModuleManager { return this.getRepository('shard').getPeersToDial(limit, dialFrequencyMillis); } - async removePeerRecords(peerRecords) { - return this.getRepository('shard').removePeerRecords(peerRecords); + async removePeerRecord(blockchain, peerId) { + return this.getRepository('shard').removePeerRecord(blockchain, peerId); } async updatePeerRecordLastDialed(peerId, timestamp) { diff --git a/src/service/blockchain-event-listener-service.js b/src/service/blockchain-event-listener-service.js index a6a458139..2ce399559 100644 --- a/src/service/blockchain-event-listener-service.js +++ b/src/service/blockchain-event-listener-service.js @@ -282,7 +282,7 @@ class BlockchainEventListenerService { } async handleNodeRemovedEvents(blockEvents) { - const peerRecords = await Promise.all( + await Promise.all( blockEvents.map(async (event) => { const eventData = JSON.parse(event.data); @@ -292,14 +292,10 @@ class BlockchainEventListenerService { ); this.logger.trace(`Removing peer id: ${nodeId} from sharding table.`); - return { - peerId: nodeId, - blockchainId: event.blockchainId, - }; + + this.repositoryModuleManager.removePeerRecord(event.blockchainId, nodeId); }), ); - - await this.repositoryModuleManager.removePeerRecords(peerRecords); } async handleStakeIncreasedEvents(blockEvents) {