From 73a4450ee2883a69c1823bc412e9450aa6fc390a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 10 Feb 2023 21:34:40 +0100 Subject: [PATCH 1/4] port of home-community base on <...PORT> + (V1_0 = 5010, V2_0 = 5020) --- dht-node/src/dht_node/index.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index ab81792df..2fd6cd1e7 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/', From fa97a5ea8b2c57db48229a599fd53fa4786f7aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Fri, 10 Feb 2023 21:55:02 +0100 Subject: [PATCH 2/4] correct the default port to the new number range beginning from 5000 plus api-version as number => 5000 + V1_0 = 5010, V2_0 = 5020 --- dht-node/.env.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dht-node/.env.dist b/dht-node/.env.dist index 94c3a5854..82050b2af 100644 --- a/dht-node/.env.dist +++ b/dht-node/.env.dist @@ -18,4 +18,4 @@ TYPEORM_LOGGING_RELATIVE_PATH=typeorm.dht-node.log FEDERATION_DHT_TOPIC=GRADIDO_HUB # FEDERATION_DHT_SEED=64ebcb0e3ad547848fef4197c6e2332f # FEDERATION_COMMUNITY_URL=http://localhost -# FEDERATION_COMMUNITY_API_PORT=5010 +# FEDERATION_COMMUNITY_API_PORT=5000 From 58d66c40afbca3111dd5903f3d4e191d0b50bca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Mon, 13 Feb 2023 20:53:38 +0100 Subject: [PATCH 3/4] rework PR-comments --- dht-node/.env.dist | 2 -- dht-node/src/dht_node/index.test.ts | 3 +-- dht-node/src/dht_node/index.ts | 4 +++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dht-node/.env.dist b/dht-node/.env.dist index 82050b2af..5d287ee1a 100644 --- a/dht-node/.env.dist +++ b/dht-node/.env.dist @@ -1,5 +1,3 @@ -CONFIG_VERSION=v2.2023-02-03 - # Database DB_HOST=localhost DB_PORT=3306 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 2fd6cd1e7..dcbb222ee 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -200,11 +200,13 @@ async function writeHomeCommunityEnries(pubKey: any): Promise { }) try { // first remove privious existing homeCommunity entries + DbCommunity.createQueryBuilder().delete().where({ foreign: false }).execute() + /* const homeComs = await DbCommunity.find({ foreign: false }) if (homeComs.length > 0) { await DbCommunity.remove(homeComs) } - + */ homeApiVersions.forEach(async function (homeApi) { const homeCom = new DbCommunity() homeCom.foreign = false From 0bd43b2e39c1317263d8681f7a78582474dcb671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus-Peter=20H=C3=BCbner?= Date: Mon, 13 Feb 2023 20:56:17 +0100 Subject: [PATCH 4/4] remove commented code --- dht-node/src/dht_node/index.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index dcbb222ee..dd25d8d81 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -201,12 +201,7 @@ async function writeHomeCommunityEnries(pubKey: any): Promise { try { // first remove privious existing homeCommunity entries DbCommunity.createQueryBuilder().delete().where({ foreign: false }).execute() - /* - const homeComs = await DbCommunity.find({ foreign: false }) - if (homeComs.length > 0) { - await DbCommunity.remove(homeComs) - } - */ + homeApiVersions.forEach(async function (homeApi) { const homeCom = new DbCommunity() homeCom.foreign = false