Skip to content

Commit e87f628

Browse files
committed
Merge pull request #439 from braydonf/zmqcheck
bitcoind: added zmq precondition
2 parents a63fac3 + cf16a23 commit e87f628

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/services/bitcoind.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ Bitcoin.prototype._checkConfigIndexes = function(spawnConfig, node) {
405405
'Please add "zmqpubhashblock=tcp://127.0.0.1:<port>" to your configuration and restart'
406406
);
407407

408+
$.checkState(
409+
(spawnConfig.zmqpubhashblock === spawnConfig.zmqpubrawtx),
410+
'"zmqpubrawtx" and "zmqpubhashblock" are expected to the same host and port in bitcoin.conf'
411+
);
412+
408413
if (spawnConfig.reindex && spawnConfig.reindex === 1) {
409414
log.warn('Reindex option is currently enabled. This means that bitcoind is undergoing a reindex. ' +
410415
'The reindex flag will start the index from beginning every time the node is started, so it ' +

test/services/bitcoind.unit.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ describe('Bitcoin Service', function() {
467467
beforeEach(function() {
468468
sandbox.stub(log, 'warn');
469469
});
470-
after(function() {
470+
afterEach(function() {
471471
sandbox.restore();
472472
});
473473
it('should warn the user if reindex is set to 1 in the bitcoin.conf file', function() {
@@ -486,6 +486,22 @@ describe('Bitcoin Service', function() {
486486
log.warn.callCount.should.equal(1);
487487
node._reindex.should.equal(true);
488488
});
489+
it('should warn if zmq port and hosts do not match', function() {
490+
var bitcoind = new BitcoinService(baseConfig);
491+
var config = {
492+
txindex: 1,
493+
addressindex: 1,
494+
spentindex: 1,
495+
server: 1,
496+
zmqpubrawtx: 'tcp://127.0.0.1:28332',
497+
zmqpubhashblock: 'tcp://127.0.0.1:28331',
498+
reindex: 1
499+
};
500+
var node = {};
501+
(function() {
502+
bitcoind._checkConfigIndexes(config, node);
503+
}).should.throw('"zmqpubrawtx" and "zmqpubhashblock"');
504+
});
489505
});
490506

491507
describe('#_resetCaches', function() {

0 commit comments

Comments
 (0)