From f875cd116fe18cfa29e8a9e376425dfcceca2e56 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 18 Mar 2023 14:49:36 -0400 Subject: [PATCH] *update dist --- dist/network.d.ts.map | 2 +- dist/network.js | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dist/network.d.ts.map b/dist/network.d.ts.map index 84eb070..800ce2c 100644 --- a/dist/network.d.ts.map +++ b/dist/network.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,kBAAkB,CAAC;AAItD,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,CAAC,uBAAuB,CAAC,CAAgB;IAChD,OAAO,CAAC,uBAAuB,CAAC,CAAW;gBAC/B,KAAK,MAAmB;IAKpC,OAAO,CAAC,QAAQ,CAA4D;IAE5E,IAAI,OAAO,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAEtC;IAED,OAAO,CAAC,QAAQ,CAAoC;IAEpD,IAAI,OAAO,IAAI,sBAAsB,CAEpC;IAED,OAAO,CAAC,MAAM,CAAoB;IAElC,IAAI,KAAK,QAER;IAED,OAAO,CAAC,kBAAkB,CAAQ;IAElC,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAElC;IAED,OAAO,CAAC,aAAa,CAAM;IAE3B,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,OAAO,CAAC,aAAa,CAAK;IAE1B,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,OAAO,CAAC,OAAO,CAAiD;IAEhE,IAAI,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE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M,CAEzB;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED,OAAO,CAAC,OAAO,CAAiD;IAEhE,IAAI,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAElC;IAED,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/B,IAAI,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAMzB;IAED,IAAI,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAEnC;IAED,OAAO,CAAC,YAAY,CAAkB;IAEtC,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,IAAI,WAAW,CAAC,KAAK,EAAE,OAAO,EAE7B;IAEM,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAYhD,QAAQ,CAAC,MAAM,EAAE,MAAM;IAQ9B,OAAO,CAAC,IAAI;IAwCZ,OAAO,CAAC,iBAAiB;CAK1B"} \ No newline at end of file diff --git a/dist/network.js b/dist/network.js index ccfa674..e146b9d 100644 --- a/dist/network.js +++ b/dist/network.js @@ -82,22 +82,8 @@ export default class RpcNetwork { this._swarm.join(createHash("lumeweb")); this.setupRelayPromise(); this._swarm.on("connection", async (relay) => { - const query = this._factory.simple({ - relay, - query: { module: "core", method: "get_methods", data: null }, - }); - const resp = await query.result; const pubkey = b4a.from(relay.remotePublicKey).toString("hex"); - if (resp.data) { - this._relays.set(pubkey, relay); - resp.data.forEach((item) => { - const methods = this._methods.get(item) ?? new Set(); - methods.add(pubkey); - this._methods.set(item, methods); - }); - this._relaysAvailableResolve?.(); - } - relay.on("close", () => { + relay.once("close", () => { this._methods.forEach((item) => { if (item.has(pubkey)) { item.delete(pubkey); @@ -108,6 +94,20 @@ export default class RpcNetwork { this.setupRelayPromise(); } }); + const query = this._factory.simple({ + relay, + query: { module: "core", method: "get_methods", data: null }, + }); + const resp = await query.result; + if (resp.data) { + this._relays.set(pubkey, relay); + resp.data.forEach((item) => { + const methods = this._methods.get(item) ?? new Set(); + methods.add(pubkey); + this._methods.set(item, methods); + }); + this._relaysAvailableResolve?.(); + } }); } setupRelayPromise() {