From d18cff1c425573a0ef461914fbf9ae2e6789fd43 Mon Sep 17 00:00:00 2001 From: Alex Werner Date: Wed, 2 Dec 2020 03:28:06 +0100 Subject: [PATCH 1/8] feat: add DashdZMQ dependency --- package-lock.json | 29 +++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 30 insertions(+) diff --git a/package-lock.json b/package-lock.json index 4e61ae953..6830bf997 100644 --- a/package-lock.json +++ b/package-lock.json @@ -117,6 +117,35 @@ } } }, + "@dashevo/dashd-zmq": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@dashevo/dashd-zmq/-/dashd-zmq-1.0.1.tgz", + "integrity": "sha512-b5osAZoOLfReds4Wx5OBm/+uir8oty8ShBe/8LQdz0X5gY1wPWna3dNhDq05yhzTdR8B/PlmasRgzgARVc/wOQ==", + "requires": { + "@types/node": "^14.11.2", + "zeromq": "^6.0.0-beta.6" + }, + "dependencies": { + "@types/node": { + "version": "14.14.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.10.tgz", + "integrity": "sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ==" + }, + "node-gyp-build": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", + "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==" + }, + "zeromq": { + "version": "6.0.0-beta.6", + "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-6.0.0-beta.6.tgz", + "integrity": "sha512-wLf6M7pBHijl+BRltUL2VoDpgbQcOZetiX8UzycHL8CcYFxYnRrpoG5fi3UX3+Umavz1lk4/dGaQez8qiDgr/Q==", + "requires": { + "node-gyp-build": "^4.1.0" + } + } + } + }, "@dashevo/x11-hash-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@dashevo/x11-hash-js/-/x11-hash-js-1.0.2.tgz", diff --git a/package.json b/package.json index 20a3fe6b9..685bb90e0 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "dependencies": { "@dashevo/dashcore-lib": "^0.19.5", "@dashevo/dashd-rpc": "^2.0.2", + "@dashevo/dashd-zmq": "^1.0.1", "async": "^2.6.1", "body-parser": "^1.18.3", "colors": "^1.3.3", From a73619a9cd9a51475c4d7b87ff7d32e4aaf39fa4 Mon Sep 17 00:00:00 2001 From: Alex Werner Date: Wed, 2 Dec 2020 03:35:44 +0100 Subject: [PATCH 2/8] feat: update to dashd-zmq client --- lib/services/dashd.js | 96 +++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/lib/services/dashd.js b/lib/services/dashd.js index d5311d970..bc0b01ec6 100644 --- a/lib/services/dashd.js +++ b/lib/services/dashd.js @@ -6,9 +6,9 @@ var spawn = require('child_process').spawn; var util = require('util'); var mkdirp = require('mkdirp'); var dashcore = require('@dashevo/dashcore-lib'); -var zmq = require('zeromq'); var async = require('async'); var LRU = require('lru-cache'); +var DashdZMQ = require('@dashevo/dashd-zmq'); var DashdRPC = require('@dashevo/dashd-rpc'); var $ = dashcore.util.preconditions; var _ = dashcore.deps._; @@ -771,46 +771,57 @@ Dash.prototype._checkSyncedAndSubscribeZmqEvents = function(node) { Dash.prototype._subscribeZmqEvents = function(node) { var self = this; - node.zmqSubSocket.subscribe('hashblock'); - node.zmqSubSocket.subscribe('rawtx'); - node.zmqSubSocket.subscribe('rawtxlock'); - node.zmqSubSocket.on('message', function(topic, message) { - var topicString = topic.toString('utf8'); - if (topicString === 'rawtxlock') { - self._zmqTransactionLockHandler(node, message); - } else if (topicString === 'rawtx') { - self._zmqTransactionHandler(node, message); - } else if (topicString === 'hashblock') { - self._zmqBlockHandler(node, message); - } + node.zmqSubSocket.subscribe(DashdZMQ.TOPICS.hashblock); + node.zmqSubSocket.on(DashdZMQ.TOPICS.hashblock, (message) => { + self._zmqBlockHandler(node, Buffer.from(message, 'hex')); + }); + + node.zmqSubSocket.subscribe(DashdZMQ.TOPICS.rawtx); + node.zmqSubSocket.on(DashdZMQ.TOPICS.rawtx, (message) => { + self._zmqTransactionHandler(node, Buffer.from(message, 'hex')); + }); + + node.zmqSubSocket.subscribe(DashdZMQ.TOPICS.rawtxlock); + node.zmqSubSocket.on(DashdZMQ.TOPICS.rawtxlock, (message) => { + self._zmqTransactionLockHandler(node, Buffer.from(message, 'hex')); }); }; Dash.prototype._initZmqSubSocket = function(node, zmqUrl) { var self = this; - node.zmqSubSocket = zmq.socket('sub'); + return new Promise((resolve) => { + const [protocol, path] = zmqUrl.split('//'); + const [host, port] = path.split(':'); + + node.zmqSubSocket = new DashdZMQ({ + protocol: protocol.slice(0, -1), + host, + port + }); - node.zmqSubSocket.on('connect', function(fd, endPoint) { - log.info('ZMQ connected to:', endPoint); - }); + node.zmqSubSocket.on('connect', function (info) { + log.info('ZMQ connected to:', info.address); + }); - node.zmqSubSocket.on('connect_delay', function(fd, endPoint) { - log.warn('ZMQ connection delay:', endPoint); - }); + node.zmqSubSocket.on('connect_delay', function(fd, endPoint) { + log.warn('ZMQ connection delay:', endPoint); + }); - node.zmqSubSocket.on('disconnect', function(fd, endPoint) { - log.warn('ZMQ disconnect:', endPoint); - }); + node.zmqSubSocket.on('disconnect', function(fd, endPoint) { + log.warn('ZMQ disconnect:', endPoint); + }); - node.zmqSubSocket.on('monitor_error', function(err) { - log.error('Error in monitoring: %s, will restart monitoring in 5 seconds', err); - setTimeout(function() { - self.zmqSubSocket.monitor(500, 0); - }, 5000); - }); + node.zmqSubSocket.on('monitor_error', function(err) { + log.error('Error in monitoring: %s, will restart monitoring in 5 seconds', err); + setTimeout(function() { + self.zmqSubSocket.monitor(500, 0); + }, 5000); + }); - node.zmqSubSocket.monitor(500, 0); - node.zmqSubSocket.connect(zmqUrl); + node.zmqSubSocket + .connect() + .then(resolve); + }); }; Dash.prototype._checkReindex = function(node, callback) { @@ -975,16 +986,19 @@ Dash.prototype._spawnChildProcess = function(callback) { return callback(new Error('Stopping while trying to spawn dashd.')); } - self._initZmqSubSocket(node, self.spawn.config.zmqpubrawtx); + self._initZmqSubSocket(node, self.spawn.config.zmqpubrawtx) + .then(() => { + self._checkReindex(node, function (err) { - self._checkReindex(node, function(err) { - if (err) { - return callback(err); - } - self._checkSyncedAndSubscribeZmqEvents(node); - callback(null, node); - }); + if (err) { + return callback(err); + } + + self._checkSyncedAndSubscribeZmqEvents(node); + callback(null, node); + }); + }); }); }); @@ -1021,8 +1035,10 @@ Dash.prototype._connectProcess = function(config, callback) { return callback(new Error('Stopping while trying to connect to dashd.')); } - self._initZmqSubSocket(node, config.zmqpubrawtx); + self._initZmqSubSocket(node, config.zmqpubrawtx) + .then(() => { self._subscribeZmqEvents(node); + }); callback(null, node); }); From 0f1a0fd1bd00d2df8c4fe4a1ea01ba1c8426bf92 Mon Sep 17 00:00:00 2001 From: Alex Werner Date: Wed, 2 Dec 2020 10:07:15 +0100 Subject: [PATCH 3/8] chore: use lts node for travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8cd89d6f5..ea57c2fde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js sudo: false node_js: - - '8' - - '10' + - '12' + - '14' env: - CXX=g++-4.8 CC=gcc-4.8 addons: From f18d236e02ecb1355b448d81f048df7498651a47 Mon Sep 17 00:00:00 2001 From: Alex Werner Date: Wed, 2 Dec 2020 10:07:25 +0100 Subject: [PATCH 4/8] chore: removed zeromq as package --- package-lock.json | 424 +--------------------------------------------- package.json | 3 +- 2 files changed, 10 insertions(+), 417 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6830bf997..1e7ec7f50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -198,7 +198,8 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true }, "ansi-styles": { "version": "2.2.1", @@ -206,20 +207,6 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" - }, - "are-we-there-yet": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", - "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -413,11 +400,6 @@ "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" }, - "base64-js": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", - "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" - }, "base64id": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", @@ -456,33 +438,6 @@ "callsite": "1.0.0" } }, - "bl": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", - "integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==", - "requires": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - }, - "dependencies": { - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, "blob": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", @@ -581,15 +536,6 @@ "base-x": "^3.0.2" } }, - "buffer": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", - "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", - "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" - } - }, "bufferutil": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.1.tgz", @@ -672,11 +618,6 @@ "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, - "chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" - }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -708,11 +649,6 @@ "glob": "^7.1.1" } }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" - }, "collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", @@ -771,11 +707,6 @@ "date-now": "^0.1.4" } }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" - }, "content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -814,7 +745,8 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true }, "coveralls": { "version": "3.0.6", @@ -866,14 +798,6 @@ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" }, - "decompress-response": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", - "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", - "requires": { - "mimic-response": "^2.0.0" - } - }, "deep-eql": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", @@ -883,11 +807,6 @@ "type-detect": "^4.0.0" } }, - "deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" - }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -937,11 +856,6 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" - }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -957,11 +871,6 @@ "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=" }, - "detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" - }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", @@ -1059,14 +968,6 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, - "end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "requires": { - "once": "^1.4.0" - } - }, "engine.io": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.3.2.tgz", @@ -1257,11 +1158,6 @@ } } }, - "expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" - }, "expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", @@ -1551,32 +1447,12 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, - "fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, "get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", @@ -1597,11 +1473,6 @@ "assert-plus": "^1.0.0" } }, - "github-from-package": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" - }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -1715,11 +1586,6 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" - }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -1866,11 +1732,6 @@ "safer-buffer": ">= 2.1.2 < 3" } }, - "ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" - }, "indexof": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", @@ -1995,14 +1856,6 @@ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, "is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", @@ -2390,11 +2243,6 @@ "mime-db": "1.40.0" } }, - "mimic-response": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", - "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==" - }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", @@ -2446,11 +2294,6 @@ "minimist": "0.0.8" } }, - "mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" - }, "mocha": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz", @@ -2530,11 +2373,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "nan": { - "version": "2.14.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", - "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" - }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -2553,11 +2391,6 @@ "to-regex": "^3.0.1" } }, - "napi-build-utils": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", - "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" - }, "native-promise-only": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", @@ -2575,14 +2408,6 @@ "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "dev": true }, - "node-abi": { - "version": "2.19.1", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.19.1.tgz", - "integrity": "sha512-HbtmIuByq44yhAzK7b9j/FelKlHYISKQn0mtvcBrU5QBkhoCMp5bu8Hv5AI34DcKfOAcJBcOEMwLlwO62FFu9A==", - "requires": { - "semver": "^5.4.1" - } - }, "node-buffers": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/node-buffers/-/node-buffers-0.1.1.tgz", @@ -2595,11 +2420,6 @@ "integrity": "sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w==", "optional": true }, - "noop-logger": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", - "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=" - }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -2609,33 +2429,12 @@ "abbrev": "1" } }, - "npmlog": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", "dev": true }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" - }, "object-component": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", @@ -2717,6 +2516,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } @@ -2854,46 +2654,12 @@ "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=" }, - "prebuild-install": { - "version": "5.3.6", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.6.tgz", - "integrity": "sha512-s8Aai8++QQGi4sSbs/M1Qku62PFK49Jm1CbgXklGz4nmHveDq0wzJkg7Na5QbnO1uNH8K7iqx2EQ/mV0MZEmOg==", - "requires": { - "detect-libc": "^1.0.3", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^1.0.1", - "node-abi": "^2.7.0", - "noop-logger": "^0.1.1", - "npmlog": "^4.0.1", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^3.0.3", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0", - "which-pm-runs": "^1.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" - } - } - }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, "proxy-addr": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", @@ -2930,15 +2696,6 @@ "integrity": "sha512-avHdspHO+9rQTLbv1RO+MPYeP/SzsCoxofjVnHanETfQhTJrmB0HlDoW+EiN/R+C0BZ+gERab9NY0lPN2TxNag==", "dev": true }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -2966,50 +2723,6 @@ "unpipe": "1.0.0" } }, - "rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" - } - } - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - }, - "dependencies": { - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - } - } - }, "rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", @@ -3192,11 +2905,6 @@ "send": "0.17.1" } }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", @@ -3229,26 +2937,6 @@ "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", "dev": true }, - "signal-exit": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" - }, - "simple-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" - }, - "simple-get": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz", - "integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==", - "requires": { - "decompress-response": "^4.2.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, "sinon": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/sinon/-/sinon-2.4.1.tgz", @@ -3581,44 +3269,15 @@ "strip-ansi": "^3.0.0" } }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - } - } - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, "requires": { "ansi-regex": "^2.0.0" } }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" - }, "supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", @@ -3628,46 +3287,6 @@ "has-flag": "^3.0.0" } }, - "tar-fs": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.0.tgz", - "integrity": "sha512-9uW5iDvrIMCVpvasdFHW0wJPez0K4JnMZtsuIeDI7HyMGJNxmDZDOCQROr7lXyS+iL/QMpj07qcjGYTSdRFXUg==", - "requires": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.0.0" - } - }, - "tar-stream": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.4.tgz", - "integrity": "sha512-o3pS2zlG4gxr67GmFYBLlq+dM8gyRGUOvsrHclSkvtVtQbjV0s/+ZE8OpICbaj8clrX3tjeHngYGP7rweaBnuw==", - "requires": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "dependencies": { - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, "text-encoding": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", @@ -3750,6 +3369,7 @@ "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, "requires": { "safe-buffer": "^5.0.1" } @@ -3894,11 +3514,6 @@ "node-gyp-build": "~3.7.0" } }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -3934,19 +3549,6 @@ "isexe": "^2.0.0" } }, - "which-pm-runs": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", - "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=" - }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "requires": { - "string-width": "^1.0.2 || 2" - } - }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", @@ -3956,7 +3558,8 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "ws": { "version": "6.1.4", @@ -3980,15 +3583,6 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" - }, - "zeromq": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-5.2.0.tgz", - "integrity": "sha512-qsckhCmrg6et6zrAJytC971SSN/4iLxKgkXK1Wqn2Gij5KXMY+TA+3cy/iFwehaWdU5usg5HNOOgaBdjSqtCVw==", - "requires": { - "nan": "^2.14.0", - "prebuild-install": "^5.3.2" - } } } } diff --git a/package.json b/package.json index 685bb90e0..d0f36dd7c 100644 --- a/package.json +++ b/package.json @@ -61,8 +61,7 @@ "path-is-absolute": "^1.0.1", "semver": "^5.7.0", "socket.io": "^2.2.0", - "socket.io-client": "^2.2.0", - "zeromq": "^5.2.0" + "socket.io-client": "^2.2.0" }, "optionalDependencies": { "bufferutil": "~4.0.1", From 88d1bf9a9c010d00f68923998e512f47a88db71f Mon Sep 17 00:00:00 2001 From: Alex Werner Date: Tue, 8 Dec 2020 12:51:40 +0100 Subject: [PATCH 5/8] build: gcc 8 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea57c2fde..1aa5099df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,14 @@ node_js: - '12' - '14' env: - - CXX=g++-4.8 CC=gcc-4.8 + - CXX=g++-8 CC=gcc-8 addons: apt: sources: - ubuntu-toolchain-r-test packages: - - g++-4.8 - - gcc-4.8 + - g++-8 + - gcc-8 - libzmq3-dev script: From 13fa1c63725376911ad43165b5b820ebd0e99399 Mon Sep 17 00:00:00 2001 From: Alex Werner Date: Tue, 8 Dec 2020 14:12:21 +0100 Subject: [PATCH 6/8] test: fixing test for dashd --- lib/services/dashd.js | 5 ++-- test/services/dashd.unit.js | 49 +++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/lib/services/dashd.js b/lib/services/dashd.js index 9d67c0e7c..5a013802b 100644 --- a/lib/services/dashd.js +++ b/lib/services/dashd.js @@ -1040,9 +1040,8 @@ Dash.prototype._connectProcess = function(config, callback) { return callback(new Error('Stopping while trying to connect to dashd.')); } - self._initZmqSubSocket(node, config.zmqpubrawtx) - .then(() => { - self._subscribeZmqEvents(node); + self._initZmqSubSocket(node, config.zmqpubrawtx).then(() => { + self._subscribeZmqEvents(node); }); callback(null, node); diff --git a/test/services/dashd.unit.js b/test/services/dashd.unit.js index 51adb265d..de0746275 100644 --- a/test/services/dashd.unit.js +++ b/test/services/dashd.unit.js @@ -1432,13 +1432,13 @@ describe('Dash Service', function() { }; node.zmqSubSocket.subscribe = sinon.stub(); dashd._subscribeZmqEvents(node); - node.zmqSubSocket.on('message', function() { + node.zmqSubSocket.on('rawtx', function() { dashd._zmqTransactionHandler.callCount.should.equal(1); done(); }); var topic = new Buffer('rawtx', 'utf8'); var message = new Buffer('abcdef', 'hex'); - node.zmqSubSocket.emit('message', topic, message); + node.zmqSubSocket.emit('rawtx', message); }); it('will call relevant handler for hashblock topics', function(done) { var dashd = new DashService(baseConfig); @@ -1448,13 +1448,13 @@ describe('Dash Service', function() { }; node.zmqSubSocket.subscribe = sinon.stub(); dashd._subscribeZmqEvents(node); - node.zmqSubSocket.on('message', function() { + node.zmqSubSocket.on('hashblock', function() { dashd._zmqBlockHandler.callCount.should.equal(1); done(); }); var topic = new Buffer('hashblock', 'utf8'); var message = new Buffer('abcdef', 'hex'); - node.zmqSubSocket.emit('message', topic, message); + node.zmqSubSocket.emit('hashblock', message); }); it('will ignore unknown topic types', function(done) { var dashd = new DashService(baseConfig); @@ -1475,32 +1475,29 @@ describe('Dash Service', function() { node.zmqSubSocket.emit('message', topic, message); }); }); - describe('#_initZmqSubSocket', function() { it('will setup zmq socket', function() { var socket = new EventEmitter(); - socket.monitor = sinon.stub(); - socket.connect = sinon.stub(); + socket.host = '0.0.0.0'; + socket.isConnected = true; + socket.port = '3000'; + socket.protocol = 'tcp'; + socket.events = {}; var socketFunc = function() { return socket; }; - var DashService = proxyquire('../../lib/services/dashd', { - zeromq: { - socket: socketFunc - } - }); + var DashService = require('../../lib/services/dashd'); var dashd = new DashService(baseConfig); var node = {}; - dashd._initZmqSubSocket(node, 'url'); - node.zmqSubSocket.should.equal(socket); - socket.connect.callCount.should.equal(1); - socket.connect.args[0][0].should.equal('url'); - socket.monitor.callCount.should.equal(1); - socket.monitor.args[0][0].should.equal(500); - socket.monitor.args[0][1].should.equal(0); + dashd._initZmqSubSocket(node, 'tcp://0.0.0.0:3000').then(()=>{ + node.zmqSubSocket.host.should.equal(socket.host); + node.zmqSubSocket.isConnected.should.equal(socket.isConnected); + node.zmqSubSocket.port.should.equal(socket.port); + node.zmqSubSocket.protocol.should.equal(socket.protocol); + node.zmqSubSocket.close(); + }); }); }); - describe('#_checkReindex', function() { var sandbox = sinon.sandbox.create(); before(function() { @@ -1826,7 +1823,7 @@ describe('Dash Service', function() { dashd.spawn.config.zmqpubrawtxlock = 'tcp://127.0.0.1:30001'; dashd._loadTipFromNode = sinon.stub().callsArgWith(1, null); - dashd._initZmqSubSocket = sinon.stub(); + dashd._initZmqSubSocket = sinon.stub().resolves(); dashd._checkSyncedAndSubscribeZmqEvents = sinon.stub(); dashd._checkReindex = sinon.stub().callsArgWith(1, null); dashd._spawnChildProcess(function(err, node) { @@ -1872,7 +1869,7 @@ describe('Dash Service', function() { dashd.spawn.config = {}; dashd.spawnRestartTime = 1; dashd._loadTipFromNode = sinon.stub().callsArg(1); - dashd._initZmqSubSocket = sinon.stub(); + dashd._initZmqSubSocket = sinon.stub().resolves(); dashd._checkReindex = sinon.stub().callsArg(1); dashd._checkSyncedAndSubscribeZmqEvents = sinon.stub(); dashd._stopSpawnedDash = sinon.stub().callsArg(0); @@ -1910,7 +1907,7 @@ describe('Dash Service', function() { dashd.spawn.config = {}; dashd.spawnRestartTime = 1; dashd._loadTipFromNode = sinon.stub().callsArg(1); - dashd._initZmqSubSocket = sinon.stub(); + dashd._initZmqSubSocket = sinon.stub().resolves(); dashd._checkReindex = sinon.stub().callsArg(1); dashd._checkSyncedAndSubscribeZmqEvents = sinon.stub(); dashd._stopSpawnedDash = sinon.stub().callsArg(0); @@ -1957,7 +1954,7 @@ describe('Dash Service', function() { dashd.spawn.config = {}; dashd.spawnRestartTime = 1; dashd._loadTipFromNode = sinon.stub().callsArg(1); - dashd._initZmqSubSocket = sinon.stub(); + dashd._initZmqSubSocket = sinon.stub().resolves();; dashd._checkReindex = sinon.stub().callsArg(1); dashd._checkSyncedAndSubscribeZmqEvents = sinon.stub(); dashd._stopSpawnedDash = sinon.stub().callsArg(0); @@ -2033,7 +2030,7 @@ describe('Dash Service', function() { dashd.spawn.config.zmqpubrawtxlock = 'tcp://127.0.0.1:30001'; dashd._loadTipFromNode = sinon.stub().callsArgWith(1, null); - dashd._initZmqSubSocket = sinon.stub(); + dashd._initZmqSubSocket = sinon.stub().resolves(); dashd._checkSyncedAndSubscribeZmqEvents = sinon.stub(); dashd._checkReindex = sinon.stub().callsArgWith(1, new Error('test')); @@ -2079,7 +2076,7 @@ describe('Dash Service', function() { }); it('will init zmq/rpc on node', function(done) { var dashd = new DashService(baseConfig); - dashd._initZmqSubSocket = sinon.stub(); + dashd._initZmqSubSocket = sinon.stub().resolves(); dashd._subscribeZmqEvents = sinon.stub(); dashd._loadTipFromNode = sinon.stub().callsArgWith(1, null); var config = {}; From 21ca0e2bd241d8b24489521afc241007b3278936 Mon Sep 17 00:00:00 2001 From: Alex Werner Date: Thu, 10 Dec 2020 16:33:07 +0100 Subject: [PATCH 7/8] feat: use URI and increase reconnection interval --- lib/services/dashd.js | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/lib/services/dashd.js b/lib/services/dashd.js index 5a013802b..b629afd8d 100644 --- a/lib/services/dashd.js +++ b/lib/services/dashd.js @@ -793,38 +793,28 @@ Dash.prototype._subscribeZmqEvents = function(node) { }; Dash.prototype._initZmqSubSocket = function(node, zmqUrl) { - var self = this; - return new Promise((resolve) => { - const [protocol, path] = zmqUrl.split('//'); - const [host, port] = path.split(':'); + return new Promise((resolve) => { node.zmqSubSocket = new DashdZMQ({ - protocol: protocol.slice(0, -1), - host, - port + uri: zmqUrl }); node.zmqSubSocket.on('connect', function (info) { log.info('ZMQ connected to:', info.address); }); - node.zmqSubSocket.on('connect_delay', function(fd, endPoint) { - log.warn('ZMQ connection delay:', endPoint); + node.zmqSubSocket.on('connect:delay', function(info) { + log.warn('ZMQ connection delay:', info.address); }); - node.zmqSubSocket.on('disconnect', function(fd, endPoint) { - log.warn('ZMQ disconnect:', endPoint); + node.zmqSubSocket.on('disconnect', function(info) { + log.warn('ZMQ disconnect:', info.address); }); - node.zmqSubSocket.on('monitor_error', function(err) { - log.error('Error in monitoring: %s, will restart monitoring in 5 seconds', err); - setTimeout(function() { - self.zmqSubSocket.monitor(500, 0); - }, 5000); - }); + const socketOptions = { reconnectInterval: 1500 }; node.zmqSubSocket - .connect() + .connect({ socketOptions }) .then(resolve); }); }; From a7ac05eb8a767010a030fe2972a86e097a8dcd88 Mon Sep 17 00:00:00 2001 From: Alex Werner Date: Thu, 10 Dec 2020 16:41:52 +0100 Subject: [PATCH 8/8] feat: update dashd-zmq to 1.1.0 --- package-lock.json | 39 ++++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e7ec7f50..8f3d7e6a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -118,31 +118,17 @@ } }, "@dashevo/dashd-zmq": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@dashevo/dashd-zmq/-/dashd-zmq-1.0.1.tgz", - "integrity": "sha512-b5osAZoOLfReds4Wx5OBm/+uir8oty8ShBe/8LQdz0X5gY1wPWna3dNhDq05yhzTdR8B/PlmasRgzgARVc/wOQ==", + "version": "1.1.0", + "resolved": "github:dashevo/js-dashd-zmq#1ba610eaf5b21682d04f4a4546e477c93ff72090", "requires": { "@types/node": "^14.11.2", "zeromq": "^6.0.0-beta.6" }, "dependencies": { "@types/node": { - "version": "14.14.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.10.tgz", - "integrity": "sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ==" - }, - "node-gyp-build": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", - "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==" - }, - "zeromq": { - "version": "6.0.0-beta.6", - "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-6.0.0-beta.6.tgz", - "integrity": "sha512-wLf6M7pBHijl+BRltUL2VoDpgbQcOZetiX8UzycHL8CcYFxYnRrpoG5fi3UX3+Umavz1lk4/dGaQez8qiDgr/Q==", - "requires": { - "node-gyp-build": "^4.1.0" - } + "version": "14.14.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.12.tgz", + "integrity": "sha512-ASH8OPHMNlkdjrEdmoILmzFfsJICvhBsFfAum4aKZ/9U4B6M6tTmTPh+f3ttWdD74CEGV5XvXWkbyfSdXaTd7g==" } } }, @@ -3583,6 +3569,21 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" + }, + "zeromq": { + "version": "6.0.0-beta.6", + "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-6.0.0-beta.6.tgz", + "integrity": "sha512-wLf6M7pBHijl+BRltUL2VoDpgbQcOZetiX8UzycHL8CcYFxYnRrpoG5fi3UX3+Umavz1lk4/dGaQez8qiDgr/Q==", + "requires": { + "node-gyp-build": "^4.1.0" + }, + "dependencies": { + "node-gyp-build": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", + "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==" + } + } } } } diff --git a/package.json b/package.json index d0f36dd7c..1bcbf25d4 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "dependencies": { "@dashevo/dashcore-lib": "^0.19.5", "@dashevo/dashd-rpc": "^2.0.2", - "@dashevo/dashd-zmq": "^1.0.1", + "@dashevo/dashd-zmq": "^1.1.0", "async": "^2.6.1", "body-parser": "^1.18.3", "colors": "^1.3.3",