edge-currency-plugins 3.3.2 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -228,27 +228,40 @@ const asServerListInfo = _cleaners.asObject.call(void 0, _cleaners.asEither.call
228
228
  }
229
229
  },
230
230
 
231
- async updateServers(settings) {
232
- const hasServerListChanged = () => {
231
+ async updateServers(newSettings) {
232
+ const isServerListMatching = () => {
233
233
  const currentCustomServers = Object.keys(serverCache.customServers)
234
- const newServers = new Set(settings.blockbookServers)
234
+ const newServers = new Set(newSettings.blockbookServers)
235
235
  const existingServers = new Set(currentCustomServers)
236
- if (newServers.size !== existingServers.size) return true
237
- for (const server of settings.blockbookServers) {
238
- if (existingServers.has(server)) continue
239
- return true
236
+ if (newServers.size !== existingServers.size) return false
237
+ for (const server of newSettings.blockbookServers) {
238
+ if (!existingServers.has(server)) return false
240
239
  }
241
- return false
240
+ return true
242
241
  }
243
242
 
244
243
  // If no changes to the user settings, then exit early
245
244
  if (
246
- settings.enableCustomServers === serverCache.enableCustomServers &&
247
- !hasServerListChanged()
245
+ newSettings.enableCustomServers === serverCache.enableCustomServers &&
246
+ isServerListMatching()
248
247
  ) {
249
248
  return
250
249
  }
251
250
 
251
+ // Force enableCustomServers to false server list is empty because
252
+ // an empty server list would cause the wallets to never sync, and
253
+ // this is unlikely the user's intention.
254
+ // This means policy change was decided later, which makes
255
+ // `enableCustomServers` functionally only useful for disabling custom
256
+ // servers entirely even when passing a list of servers (which could have
257
+ // been done by passing an empty list to begin with).
258
+ // In other words, this field is more of an internal field to track whether
259
+ // to treat the list a static or not (whether to fetch serve lists outside
260
+ // of the list provided by the user or not).
261
+ const enableCustomServers =
262
+ newSettings.enableCustomServers &&
263
+ newSettings.blockbookServers.length !== 0
264
+
252
265
  // Stop all engines and clear the server list:
253
266
  const enginesToBeStarted = []
254
267
  const disconnects = []
@@ -264,12 +277,12 @@ const asServerListInfo = _cleaners.asObject.call(void 0, _cleaners.asEither.call
264
277
  // only using the exact customServers provided.
265
278
  serverCache = {
266
279
  ...serverCache,
267
- enableCustomServers: settings.enableCustomServers,
280
+ enableCustomServers,
268
281
  customServers: {}
269
282
  }
270
283
  serverCacheDirty = true
271
284
  await saveServerCache()
272
- await instance.refreshServers(settings.blockbookServers)
285
+ await instance.refreshServers(newSettings.blockbookServers)
273
286
  for (const engine of enginesToBeStarted) {
274
287
  await engine.start()
275
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-plugins",
3
- "version": "3.3.2",
3
+ "version": "3.4.0",
4
4
  "description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
5
5
  "homepage": "https://edge.app/",
6
6
  "repository": "https://github.com/EdgeApp/edge-currency-plugins",