Skip to content

Commit 246136e

Browse files
authored
fix: propagating nodes on database if initDB true even DB is filled (#1907)
Signed-off-by: rsercano <[email protected]>
1 parent 35e85b3 commit 246136e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: lib/db/DB.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,20 @@ class DB {
166166
SwapDeal.sync(),
167167
]);
168168

169-
if (shouldInitDb) {
169+
if (initDb) {
170170
// initialize database with the seed nodes for the configured network
171171
const nodes = defaultNodes(network);
172172
if (nodes) {
173-
await Node.bulkCreate(nodes);
173+
const existingNodes = await Models.Node(this.sequelize).findAll();
174+
const newNodes = nodes.filter(node => (!existingNodes.find(n => (n.nodePubKey === node.nodePubKey))));
175+
176+
if (newNodes.length > 0) {
177+
await Node.bulkCreate(newNodes);
178+
}
174179
}
180+
}
175181

182+
if (shouldInitDb) {
176183
// initialize database with the default currencies for the configured network
177184
const currencies = defaultCurrencies(network);
178185
if (currencies) {

0 commit comments

Comments
 (0)