diff --git a/package-lock.json b/package-lock.json index b101ae7d8..0a4c0591c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3036,9 +3036,9 @@ "dev": true }, "source-map-support": { - "version": "0.5.11", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.11.tgz", - "integrity": "sha512-//sajEx/fGL3iw6fltKMdPvy8kL3kJ2O3iuYlRoT3k9Kb4BjOoZ+BZzaNHeuaruSt+Kf3Zk9tnfAQg9/AJqUVQ==", + "version": "0.5.12", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", + "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -3161,9 +3161,9 @@ } }, "callsites": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.0.0.tgz", - "integrity": "sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, "camel-case": { @@ -4093,9 +4093,9 @@ } }, "conventional-commit-types": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/conventional-commit-types/-/conventional-commit-types-2.2.0.tgz", - "integrity": "sha1-XblXOdbCEqy+e29lahG5QLqmiUY=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/conventional-commit-types/-/conventional-commit-types-2.1.1.tgz", + "integrity": "sha512-0Ts+fEdmjqYDOQ1yZ+LNgdSPO335XZw9qC10M7CxtLP3nIMGmeMhmkM8Taffa4+MXN13bRPlp0CtH+QfOzKTzw==", "dev": true }, "conventional-commits-filter": { @@ -4712,9 +4712,9 @@ }, "dependencies": { "object-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", - "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true } } @@ -5475,9 +5475,9 @@ }, "dependencies": { "object-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", - "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true } } @@ -11400,9 +11400,9 @@ } }, "mime": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.1.tgz", - "integrity": "sha512-VRUfmQO0rCd3hKwBymAn3kxYzBHr3I/wdVMywgG3HhXOwrCQgN84ZagpdTm2tZ4TNtwsSmyJWYO88mb5XvzGqQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", + "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==", "dev": true }, "mime-db": { @@ -11956,9 +11956,9 @@ }, "dependencies": { "object-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", - "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true } } @@ -12167,9 +12167,9 @@ "dev": true }, "p-is-promise": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.0.0.tgz", - "integrity": "sha512-pzQPhYMCAgLAKPWD2jC3Se9fEfrD9npNos0y150EeqZll7akhEgGhTW/slB6lHku8AvYGiJ+YJ5hfHKePPgFWg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", "dev": true }, "p-limit": { @@ -12365,7 +12365,7 @@ "dev": true }, "peerplaysjs-lib": { - "version": "github:peerplays-network/peerplaysjs-lib#50a55b5b9080a5ec5a19e3ca61a8a75801eeadbf", + "version": "github:peerplays-network/peerplaysjs-lib#0b28f019d5f44490c8f71b36fba59e9c5296aedb", "from": "github:peerplays-network/peerplaysjs-lib", "dev": true, "requires": { @@ -12381,12 +12381,37 @@ "ecurve": "^1.0.2", "event-emitter": "^0.3.4", "immutable": "^3.7.6", - "peerplaysjs-ws": "github:peerplays-network/peerplaysjs-ws#c9e6319dd07b8601fd6977882ed7d5e64edbf58f", - "secure-random": "^1.1.1" + "peerplaysjs-ws": "github:peerplays-network/peerplaysjs-ws#38919eae7e8db8d3f4c1d7397358c4be957a1b85", + "secure-random": "^1.1.1", + "uglify-js": "^3.5.2" + }, + "dependencies": { + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "uglify-js": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.4.tgz", + "integrity": "sha512-GpKo28q/7Bm5BcX9vOu4S46FwisbPbAmkkqPnGIpKvKTM96I85N6XHQV+k4I6FA2wxgLhcsSyHoNhzucwCflvA==", + "dev": true, + "requires": { + "commander": "~2.20.0", + "source-map": "~0.6.1" + } + } } }, "peerplaysjs-ws": { - "version": "github:peerplays-network/peerplaysjs-ws#c9e6319dd07b8601fd6977882ed7d5e64edbf58f", + "version": "github:peerplays-network/peerplaysjs-ws#38919eae7e8db8d3f4c1d7397358c4be957a1b85", "from": "github:peerplays-network/peerplaysjs-ws", "dev": true, "requires": { @@ -16919,9 +16944,9 @@ } }, "spdx-license-ids": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", - "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz", + "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", "dev": true }, "speedometer": { diff --git a/src/services/CommunicationService.js b/src/services/CommunicationService.js index df3c62f0b..9717a46d9 100644 --- a/src/services/CommunicationService.js +++ b/src/services/CommunicationService.js @@ -23,6 +23,7 @@ import _ from 'lodash'; import log from 'loglevel'; import DrawerActions from '../actions/DrawerActions'; import {I18n} from 'react-redux-i18n'; +import {ConnectionManager, ChainWebSocket} from 'peerplaysjs-ws'; const TIMEOUT_LENGTH = 500; const SYNC_MIN_INTERVAL = 1000; // 1 seconds @@ -541,14 +542,25 @@ class CommunicationService { * @static * @memberof CommunicationService */ - static ping() { - // Clear the timeout, this will help prevent zombie timeout loops. + static ping(blockChainUrlIndex) { + + let currentConnectedNode = Config.blockchainUrls[blockChainUrlIndex]; + let wsConnectionManager = new ConnectionManager({ + urls: [currentConnectedNode] + }); + let conn = new ChainWebSocket(wsConnectionManager.urls); + if (CommunicationService.PING_TIMEOUT) { + // Clear the timeout, this will help prevent zombie timeout loops. CommunicationService.clearPing(); } - CommunicationService.PING_TIMEOUT = setTimeout(CommunicationService.ping, Config.pingInterval); - CommunicationService.callBlockchainDbApi('get_objects', [['2.1.0']]); + wsConnectionManager.ping(conn).then(() => { + CommunicationService.PING_TIMEOUT = + setTimeout(CommunicationService.ping, Config.pingInterval, blockChainUrlIndex); + }).catch((err) => { + console.error(err); + }); } /** diff --git a/src/services/ConnectionService.js b/src/services/ConnectionService.js index 87f0648c9..a655e970a 100644 --- a/src/services/ConnectionService.js +++ b/src/services/ConnectionService.js @@ -45,7 +45,7 @@ class ConnectionService { // Internet is on and websocket is open // Setup the health check. - CommunicationService.ping(); + CommunicationService.ping(this.blockchainUrlIndex); this.connectionStatusCallback(ConnectionStatus.CONNECTED); } else {