From d3d94c71624ed3b5cf85b97d04e05662d908eb05 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 26 Jul 2022 20:58:41 -0400 Subject: [PATCH] *Lazy load dht ready promise --- src/rpcNetwork.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpcNetwork.ts b/src/rpcNetwork.ts index e5ca994..544160a 100644 --- a/src/rpcNetwork.ts +++ b/src/rpcNetwork.ts @@ -5,7 +5,6 @@ import DHT from "@hyperswarm/dht"; export default class RpcNetwork { constructor(dht = new DHT()) { this._dht = dht; - this._ready = this._dht.ready(); } private _dht: typeof DHT; @@ -63,6 +62,9 @@ export default class RpcNetwork { private _ready: Promise; get ready(): Promise { + if (!this._ready) { + this._ready = this._dht.ready(); + } return this._ready; }