diff --git a/src/migration/pull-sharding-table-migration.js b/src/migration/pull-sharding-table-migration.js index 968cc8b9d9..6455a88dc2 100644 --- a/src/migration/pull-sharding-table-migration.js +++ b/src/migration/pull-sharding-table-migration.js @@ -67,11 +67,6 @@ class PullBlockchainShardingTableMigration extends BaseMigration { const sha256 = await this.hashingService.callHashFunction(1, nodeId); - const cleanHexString = sha256.startsWith('0x') - ? sha256.slice(2) - : sha256; - const sha256Blob = Buffer.from(cleanHexString, 'hex'); - return { peerId: nodeId, blockchainId, @@ -86,7 +81,6 @@ class PullBlockchainShardingTableMigration extends BaseMigration { 'ether', ), sha256, - sha256Blob, }; }), ), diff --git a/src/modules/repository/implementation/sequelize/migrations/20240201100000-remove-sha256Blob.js b/src/modules/repository/implementation/sequelize/migrations/20240201100000-remove-sha256Blob.js new file mode 100644 index 0000000000..25618e1d51 --- /dev/null +++ b/src/modules/repository/implementation/sequelize/migrations/20240201100000-remove-sha256Blob.js @@ -0,0 +1,17 @@ +export async function up({ context: { queryInterface } }) { + const tableInfo = await queryInterface.describeTable('shard'); + + if (tableInfo.sha256_blob) { + await queryInterface.removeColumn('shard', 'sha256_blob'); + } +} + +export async function down({ context: { queryInterface, Sequelize } }) { + const tableInfo = await queryInterface.describeTable('shard'); + + if (!tableInfo.sha256_blob) { + await queryInterface.addColumn('shard', 'sha256_blob', { + type: Sequelize.BLOB, + }); + } +} diff --git a/src/modules/repository/implementation/sequelize/models/shard.js b/src/modules/repository/implementation/sequelize/models/shard.js index 7e5b884e29..cd14aa539f 100644 --- a/src/modules/repository/implementation/sequelize/models/shard.js +++ b/src/modules/repository/implementation/sequelize/models/shard.js @@ -26,9 +26,6 @@ export default (sequelize, DataTypes) => { type: DataTypes.STRING, allowNull: false, }, - sha256Blob: { - type: DataTypes.BLOB, - }, }, { underscored: true }, ); diff --git a/src/modules/repository/implementation/sequelize/repositories/shard-repository.js b/src/modules/repository/implementation/sequelize/repositories/shard-repository.js index 25a2051633..86fb01460b 100644 --- a/src/modules/repository/implementation/sequelize/repositories/shard-repository.js +++ b/src/modules/repository/implementation/sequelize/repositories/shard-repository.js @@ -19,7 +19,7 @@ class ShardRepository { }); } - async createPeerRecord(peerId, blockchainId, ask, stake, lastSeen, sha256, sha256Blob) { + async createPeerRecord(peerId, blockchainId, ask, stake, lastSeen, sha256) { return this.model.create( { peerId, @@ -28,7 +28,6 @@ class ShardRepository { stake, lastSeen, sha256, - sha256Blob, }, { ignoreDuplicates: true, @@ -42,7 +41,6 @@ class ShardRepository { blockchainId, }, attributes: ['peerId', 'blockchainId', 'ask', 'stake', 'lastSeen', 'sha256'], - order: [['sha256Blob', 'ASC']], }; if (filterLastSeen) { diff --git a/src/service/blockchain-event-listener-service.js b/src/service/blockchain-event-listener-service.js index aca8db13f2..087854f6cd 100644 --- a/src/service/blockchain-event-listener-service.js +++ b/src/service/blockchain-event-listener-service.js @@ -349,9 +349,6 @@ class BlockchainEventListenerService { nodeId, ); - const cleanHexString = sha256.startsWith('0x') ? sha256.slice(2) : sha256; - const sha256Blob = Buffer.from(cleanHexString, 'hex'); - this.logger.trace(`Adding peer id: ${nodeId} to sharding table.`); return { peerId: nodeId, @@ -366,7 +363,6 @@ class BlockchainEventListenerService { ), lastSeen: new Date(0), sha256, - sha256Blob, }; }), ); diff --git a/src/service/sharding-table-service.js b/src/service/sharding-table-service.js index d6fd6e5718..4a5a3ff8cf 100644 --- a/src/service/sharding-table-service.js +++ b/src/service/sharding-table-service.js @@ -93,8 +93,6 @@ class ShardingTableService { ); const sha256 = await this.hashingService.callHashFunction(1, nodeId); - const cleanHexString = sha256.startsWith('0x') ? sha256.slice(2) : sha256; - const sha256Blob = Buffer.from(cleanHexString, 'hex'); return { peerId: nodeId, blockchainId, @@ -109,7 +107,6 @@ class ShardingTableService { 'ether', ), sha256, - sha256Blob, }; }), ),