diff --git a/packages/gateway-client/src/worker/p2p-client/bootstrap-list.ts b/packages/gateway-client/src/worker/p2p-client/bootstrap-list.ts index 0be79b4..3049832 100644 --- a/packages/gateway-client/src/worker/p2p-client/bootstrap-list.ts +++ b/packages/gateway-client/src/worker/p2p-client/bootstrap-list.ts @@ -191,6 +191,11 @@ export class BootstrapList extends Bootstrap { } private async dumpCache() { + // don't dump if the list is empty + if (!Object.keys(this.addresses).length) { + this.log.error('Declining to cache empty bootstrap list.'); + return; + } // dump our bootstrap list to cache return localforage.setItem( 'p2p:bootstrap-list', @@ -308,9 +313,6 @@ export class BootstrapList extends Bootstrap { this.log.info('Loaded bootstrap addresses: ', addressList); status.relays.push(...addressList); - // update our cache - await this.dumpCache(); - // if we have no addresses if (!Object.keys(this.addresses).length) { // this isn't good @@ -320,6 +322,9 @@ export class BootstrapList extends Bootstrap { return; } + // update our cache + await this.dumpCache(); + // create a bootstrap discovery list grouped by peer const addressesByPeer: Record = {}; Object.values(this.addresses).forEach(address => {