From db38090006aae2088a45210100d7a10174609863 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 30 May 2023 09:16:24 +0200 Subject: [PATCH 1/2] removed (potential) duplicate db query --- dht-node/src/dht_node/index.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index 36291904a..f0cd8eb2b 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -217,12 +217,7 @@ async function writeHomeCommunityEntry(pubKey: string): Promise { // check for existing homeCommunity entry let homeCom = await DbCommunity.findOne({ foreign: false, - publicKey: Buffer.from(pubKey), }) - if (!homeCom) { - // check if a homecommunity with a different publicKey still exists - homeCom = await DbCommunity.findOne({ foreign: false }) - } if (homeCom) { // simply update the existing entry, but it MUST keep the ID and UUID because of possible relations homeCom.publicKey = Buffer.from(pubKey) From fa7e9ee574f0f0941c9f5fa5c3672524af2cee1d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 30 May 2023 09:19:28 +0200 Subject: [PATCH 2/2] linting --- dht-node/src/dht_node/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index f0cd8eb2b..e8bfe1bda 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -215,9 +215,7 @@ async function writeFederatedHomeCommunityEntries(pubKey: string): Promise { try { // check for existing homeCommunity entry - let homeCom = await DbCommunity.findOne({ - foreign: false, - }) + let homeCom = await DbCommunity.findOne({ foreign: false }) if (homeCom) { // simply update the existing entry, but it MUST keep the ID and UUID because of possible relations homeCom.publicKey = Buffer.from(pubKey)