diff --git a/lib/index.js b/lib/index.js index 24e6dcc..0b362c9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -323,14 +323,21 @@ client.onConnect(() => { } }, pingInterval); let lastForceUpdateTime = new Date(); + let tempClient; setInterval(async () => { + if (tempClient) { + tempClient.close().catch(e => { + console.error('Close temp client error:', e); + }); + } + let tempIdentifier = _nknSdk.default.util.randomBytesHex(4); if (identifier) { tempIdentifier += '.' + identifier; } - let tempClient = new _nknSdk.default.MultiClient({ + tempClient = new _nknSdk.default.MultiClient({ originalClient: true, seed: wallet.getSeed(), identifier: tempIdentifier @@ -356,6 +363,11 @@ client.onConnect(() => { } } } + + tempClient.close().catch(e => { + console.error('Close temp client error:', e); + }); + tempClient = null; }, 3000); }); }, forcePingInterval); diff --git a/package.json b/package.json index a9da361..50f2948 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nkn-shell-daemon", - "version": "1.0.7", + "version": "1.0.9", "description": "NKN Shell Daemon", "main": "nshd.js", "bin": { diff --git a/src/index.js b/src/index.js index 8891d02..72ab327 100644 --- a/src/index.js +++ b/src/index.js @@ -303,12 +303,18 @@ client.onConnect(() => { }, pingInterval) let lastForceUpdateTime = new Date() + let tempClient setInterval(async () => { + if (tempClient) { + tempClient.close().catch((e) => { + console.error('Close temp client error:', e); + }) + } let tempIdentifier = nkn.util.randomBytesHex(4) if (identifier) { tempIdentifier += '.' + identifier } - let tempClient = new nkn.MultiClient({ + tempClient = new nkn.MultiClient({ originalClient: true, seed: wallet.getSeed(), identifier: tempIdentifier, @@ -331,6 +337,10 @@ client.onConnect(() => { } } } + tempClient.close().catch((e) => { + console.error('Close temp client error:', e); + }) + tempClient = null }, 3000); }) }, forcePingInterval)