From eb2cfb18a15b60c80554ec9423571e903308e6e4 Mon Sep 17 00:00:00 2001 From: ScottyPoi Date: Mon, 3 Feb 2025 13:38:25 -0700 Subject: [PATCH] store and rebuild cache from DB --- packages/portalnetwork/src/client/client.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/portalnetwork/src/client/client.ts b/packages/portalnetwork/src/client/client.ts index 51f15ff6b..575c7e9da 100644 --- a/packages/portalnetwork/src/client/client.ts +++ b/packages/portalnetwork/src/client/client.ts @@ -298,6 +298,10 @@ export class PortalNetwork extends EventEmitter { await this.discv5.start() await this.db.open() const storedIndex = await this.db.getBlockIndex() + const storedEnrCache = await this.db.get('enr_cache') + if (storedEnrCache) { + this.enrCache = new Map(JSON.parse(storedEnrCache)) + } for (const network of this.networks.values()) { try { // Check for stored radius in db @@ -334,6 +338,7 @@ export class PortalNetwork extends EventEmitter { await this.discv5.stop() this.discv5.removeAllListeners() this.removeAllListeners() + await this.db.put('enr_cache', JSON.stringify([...this.enrCache.entries()])) await this.db.close() for (const network of this.networks.values()) { network.stopRefresh()