From 08ec9f529d481dced912adc3bb9fbb8f683f9867 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 15 Mar 2023 17:33:37 +0000 Subject: [PATCH] [TS] Throw a reasonable error if two `NodeLDKNet`s are on one `PM` --- node-net/net.mts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/node-net/net.mts b/node-net/net.mts index 797bc7a7..9e16ab32 100644 --- a/node-net/net.mts +++ b/node-net/net.mts @@ -8,6 +8,12 @@ export class NodeLDKNet { private ping_timer; private servers: net.Server[]; public constructor(public peer_manager: ldk.PeerManager) { + // @ts-ignore + if (peer_manager._node_ldk_net_singleton_check != undefined) { + throw "Only one NdoeLDKNet should exist per PeerManager"; + } + // @ts-ignore + peer_manager._node_ldk_net_singleton_check = this; this.ping_timer = setInterval(function() { peer_manager.timer_tick_occurred(); peer_manager.process_events(); @@ -24,6 +30,8 @@ export class NodeLDKNet { server.close(); } this.peer_manager.disconnect_all_peers(); + // @ts-ignore + delete this.peer_manager._node_ldk_net_singleton_check; } /** -- 2.39.5