Skip to content

Commit

Permalink
Removing own node from seed nodes if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuakarp authored and CMCDragonkai committed Mar 26, 2022
1 parent 343c887 commit 7190ce9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/PolykeyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 7190ce9

Please sign in to comment.