From: Matt Corallo Date: Wed, 15 Mar 2023 17:33:37 +0000 (+0000) Subject: [TS] Throw a reasonable error if two `NodeLDKNet`s are on one `PM` X-Git-Tag: v0.0.114.1^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=08ec9f529d481dced912adc3bb9fbb8f683f9867;p=ldk-java [TS] Throw a reasonable error if two `NodeLDKNet`s are on one `PM` --- 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; } /**