Skip to content

Commit 7190ce9

Browse files
joshuakarpCMCDragonkai
authored andcommitted
Removing own node from seed nodes if provided
1 parent 343c887 commit 7190ce9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/PolykeyAgent.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Schema } from './schema';
1414
import { VaultManager } from './vaults';
1515
import { ACL } from './acl';
1616
import { NodeConnectionManager, NodeGraph, NodeManager } from './nodes';
17+
import * as nodesUtils from './nodes/utils';
1718
import { NotificationsManager } from './notifications';
1819
import { GestaltGraph } from './gestalts';
1920
import { Sigchain } from './sigchain';
@@ -190,6 +191,14 @@ class PolykeyAgent {
190191
logger: logger.getChild(KeyManager.name),
191192
fresh,
192193
}));
194+
// Remove your own node ID if provided as a seed node
195+
const nodeIdOwn = keyManager.getNodeId();
196+
const nodeIdEncodedOwn = Object.keys(seedNodes).find(nodeIdEncoded => {
197+
return nodeIdOwn.equals(nodesUtils.decodeNodeId(nodeIdEncoded)!);
198+
});
199+
if (nodeIdEncodedOwn != null) {
200+
delete seedNodes[nodeIdEncodedOwn];
201+
}
193202
db =
194203
db ??
195204
(await DB.createDB({

0 commit comments

Comments
 (0)