Browse Source

Updated disconnectFromPeer method in helpers/index.js.

Removed destroy from close method in Client class in lib/client.js.
Added subscribe check to onClose method in electrum_client.js.
Updated package-lock.json.
get-transaction-merkle
Corey Phillips 2 years ago
parent
commit
a98c5b182c
No known key found for this signature in database GPG Key ID: 80C0975F55D3A07B
  1. 13
      helpers/index.js
  2. 2
      lib/client.js
  3. 4
      lib/electrum_client.js
  4. 9528
      package-lock.json

13
helpers/index.js

@ -245,9 +245,6 @@ const stop = async ({ network = "" } = {}) => {
}; };
const disconnectFromPeer = async ({ id = Math.random(), network = "" } = {}) => { const disconnectFromPeer = async ({ id = Math.random(), network = "" } = {}) => {
const failure = (data = {}) => {
return { error: true, id, method: "disconnectFromPeer", data };
};
try { try {
if (clients.mainClient[network] === false) { if (clients.mainClient[network] === false) {
//No peer to disconnect from... //No peer to disconnect from...
@ -261,12 +258,18 @@ const disconnectFromPeer = async ({ id = Math.random(), network = "" } = {}) =>
} }
//Attempt to disconnect from peer... //Attempt to disconnect from peer...
clients.mainClient[network].close(); clients.mainClient[network].close();
await pauseExecution();
//Reset the client.
clients.mainClient[network] = false; clients.mainClient[network] = false;
clients.peer[network] = { port: 0, host: "", protocol: "" };
clients.peers[network] = [];
clients.subscribedAddresses[network] = [];
clients.subscribedHeaders[network] = false;
clients.onAddressReceive[network] = undefined;
clients.network = ""; clients.network = "";
await pauseExecution();
return { error: false, id, method: "disconnectFromPeer", network, data: "Disconnected..." }; return { error: false, id, method: "disconnectFromPeer", network, data: "Disconnected..." };
} catch (e) { } catch (e) {
failure(e); return { error: true, id, method: "disconnectFromPeer", data: e };
} }
}; };

2
lib/client.js

@ -34,7 +34,7 @@ class Client {
return; return;
} }
this.conn.end(); this.conn.end();
this.conn.destroy(); //this.conn.destroy();
this.status = 0; this.status = 0;
} }

4
lib/electrum_client.js

@ -12,7 +12,9 @@ class ElectrumClient extends Client{
'blockchain.headers.subscribe', 'blockchain.headers.subscribe',
'blockchain.address.subscribe' 'blockchain.address.subscribe'
] ]
list.forEach(event => this.subscribe.removeAllListeners(event)) list.forEach(event => {
if (this.subscribe) this.subscribe.removeAllListeners(event);
})
} }
server_version(client_name, protocol_version){ server_version(client_name, protocol_version){
try { try {

9528
package-lock.json

File diff suppressed because it is too large
Loading…
Cancel
Save