diff --git a/dht-node/src/dht_node/index.test.ts b/dht-node/src/dht_node/index.test.ts index 59e52149a..b7e36c783 100644 --- a/dht-node/src/dht_node/index.test.ts +++ b/dht-node/src/dht_node/index.test.ts @@ -44,11 +44,10 @@ const lookupResultMock = { token: Buffer.from(TEST_TOPIC), from: { id: Buffer.from('somone'), - foreign: true, host: '188.95.53.5', port: 63561, }, - to: { id: null, foreign: true, host: '83.53.31.27', port: 55723 }, + to: { id: null, host: '83.53.31.27', port: 55723 }, peers: [ { publicKey: Buffer.from('some-public-key'), diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index ab81792df..dd25d8d81 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -189,11 +189,9 @@ export const startDHT = async (topic: string): Promise => { } async function writeHomeCommunityEnries(pubKey: any): Promise { - const homeApiVersions: CommunityApi[] = Object.values(ApiVersionType).map(function ( - apiEnum, - idx, - ) { - const port = Number.parseInt(CONFIG.FEDERATION_COMMUNITY_API_PORT) + idx + 1 + const homeApiVersions: CommunityApi[] = Object.values(ApiVersionType).map(function (apiEnum) { + const port = + Number.parseInt(CONFIG.FEDERATION_COMMUNITY_API_PORT) + Number(apiEnum.replace('_', '')) const comApi: CommunityApi = { api: apiEnum, url: CONFIG.FEDERATION_COMMUNITY_URL + ':' + port.toString() + '/api/', @@ -202,10 +200,7 @@ async function writeHomeCommunityEnries(pubKey: any): Promise { }) try { // first remove privious existing homeCommunity entries - const homeComs = await DbCommunity.find({ foreign: false }) - if (homeComs.length > 0) { - await DbCommunity.remove(homeComs) - } + DbCommunity.createQueryBuilder().delete().where({ foreign: false }).execute() homeApiVersions.forEach(async function (homeApi) { const homeCom = new DbCommunity()