From 343c887563958e759755599c6caaae7aa0cb9931 Mon Sep 17 00:00:00 2001 From: Joshua Karp Date: Tue, 15 Feb 2022 14:32:59 +1100 Subject: [PATCH] Seed nodes: provided seed nodes should override defaults if overlapping --- src/bin/agent/CommandStart.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bin/agent/CommandStart.ts b/src/bin/agent/CommandStart.ts index 75be8c78a..211883bb6 100644 --- a/src/bin/agent/CommandStart.ts +++ b/src/bin/agent/CommandStart.ts @@ -74,8 +74,14 @@ class CommandStart extends CommandPolykey { options.recoveryCodeFile, this.fs, ); + // Will be `[{}, true]` if `--seed-nodes` is not set + // Will be '[{}, true]' if `--seed-nodes=''` + // Will be '[{...}, true]' if `--seed-nodes='...;'` + // Will be '[{}, false]' if `--seed-nodes=''` + // Will be '[{...}, false]' if `--seed-nodes='...'` const [seedNodes, defaults] = options.seedNodes; - if (defaults) Object.assign(seedNodes, options.network); + let seedNodes_ = seedNodes; + if (defaults) seedNodes_ = {...options.network, ...seedNodes}; const agentConfig = { password, nodePath: options.nodePath, @@ -92,7 +98,7 @@ class CommandStart extends CommandPolykey { proxyHost: options.proxyHost, proxyPort: options.proxyPort, }, - seedNodes, + seedNodes: seedNodes_, fresh: options.fresh, }; let recoveryCodeOut: RecoveryCode | undefined;