Skip to content

Commit

Permalink
Merge pull request #2908 from OriginTrail/fix/remove-sha256Blob
Browse files Browse the repository at this point in the history
Fix/remove sha256 blob
  • Loading branch information
djordjekovac authored Feb 1, 2024
2 parents b3da277 + 6663e5a commit 13af94d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
6 changes: 0 additions & 6 deletions src/migration/pull-sharding-table-migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -86,7 +81,6 @@ class PullBlockchainShardingTableMigration extends BaseMigration {
'ether',
),
sha256,
sha256Blob,
};
}),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export default (sequelize, DataTypes) => {
type: DataTypes.STRING,
allowNull: false,
},
sha256Blob: {
type: DataTypes.BLOB,
},
},
{ underscored: true },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,7 +28,6 @@ class ShardRepository {
stake,
lastSeen,
sha256,
sha256Blob,
},
{
ignoreDuplicates: true,
Expand All @@ -42,7 +41,6 @@ class ShardRepository {
blockchainId,
},
attributes: ['peerId', 'blockchainId', 'ask', 'stake', 'lastSeen', 'sha256'],
order: [['sha256Blob', 'ASC']],
};

if (filterLastSeen) {
Expand Down
4 changes: 0 additions & 4 deletions src/service/blockchain-event-listener-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -366,7 +363,6 @@ class BlockchainEventListenerService {
),
lastSeen: new Date(0),
sha256,
sha256Blob,
};
}),
);
Expand Down
3 changes: 0 additions & 3 deletions src/service/sharding-table-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -109,7 +107,6 @@ class ShardingTableService {
'ether',
),
sha256,
sha256Blob,
};
}),
),
Expand Down

0 comments on commit 13af94d

Please sign in to comment.