From 7190ce9ddd16abc476246f3da1506c2e29ca6071 Mon Sep 17 00:00:00 2001 From: Joshua Karp Date: Tue, 15 Feb 2022 15:18:12 +1100 Subject: [PATCH] Removing own node from seed nodes if provided --- src/PolykeyAgent.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PolykeyAgent.ts b/src/PolykeyAgent.ts index dfb4aa1ef..ae1659bcf 100644 --- a/src/PolykeyAgent.ts +++ b/src/PolykeyAgent.ts @@ -14,6 +14,7 @@ import { Schema } from './schema'; import { VaultManager } from './vaults'; import { ACL } from './acl'; import { NodeConnectionManager, NodeGraph, NodeManager } from './nodes'; +import * as nodesUtils from './nodes/utils'; import { NotificationsManager } from './notifications'; import { GestaltGraph } from './gestalts'; import { Sigchain } from './sigchain'; @@ -190,6 +191,14 @@ class PolykeyAgent { logger: logger.getChild(KeyManager.name), fresh, })); + // Remove your own node ID if provided as a seed node + const nodeIdOwn = keyManager.getNodeId(); + const nodeIdEncodedOwn = Object.keys(seedNodes).find(nodeIdEncoded => { + return nodeIdOwn.equals(nodesUtils.decodeNodeId(nodeIdEncoded)!); + }); + if (nodeIdEncodedOwn != null) { + delete seedNodes[nodeIdEncodedOwn]; + } db = db ?? (await DB.createDB({