From acbac55c8711d7d889d11b5895e269020d02edda Mon Sep 17 00:00:00 2001 From: Chethan Krishna Date: Thu, 28 Jul 2016 16:41:38 -0400 Subject: [PATCH] Use logical timestamps to display blocks --- lib/services/bitcoind.js | 8 ++++++-- test/services/bitcoind.unit.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index 8774498e2..9b458203c 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -1691,9 +1691,13 @@ Bitcoin.prototype.getBlock = function(blockArg, callback) { * @param {Number} low - The older timestamp in seconds * @param {Function} callback */ -Bitcoin.prototype.getBlockHashesByTimestamp = function(high, low, callback) { +Bitcoin.prototype.getBlockHashesByTimestamp = function(high, low, options, callback) { var self = this; - self.client.getBlockHashes(high, low, function(err, response) { + if (_.isFunction(options)) { + callback = options; + options = {}; + } + self.client.getBlockHashes(high, low, options, function(err, response) { if (err) { return callback(self._wrapRPCError(err)); } diff --git a/test/services/bitcoind.unit.js b/test/services/bitcoind.unit.js index 57819d126..374dce091 100644 --- a/test/services/bitcoind.unit.js +++ b/test/services/bitcoind.unit.js @@ -3944,7 +3944,7 @@ describe('Bitcoin Service', function() { describe('#getBlockHashesByTimestamp', function() { it('should give an rpc error', function(done) { var bitcoind = new BitcoinService(baseConfig); - var getBlockHashes = sinon.stub().callsArgWith(2, {message: 'error', code: -1}); + var getBlockHashes = sinon.stub().callsArgWith(3, {message: 'error', code: -1}); bitcoind.nodes.push({ client: { getBlockHashes: getBlockHashes @@ -3960,7 +3960,7 @@ describe('Bitcoin Service', function() { var bitcoind = new BitcoinService(baseConfig); var block1 = '00000000050a6d07f583beba2d803296eb1e9d4980c4a20f206c584e89a4f02b'; var block2 = '000000000383752a55a0b2891ce018fd0fdc0b6352502772b034ec282b4a1bf6'; - var getBlockHashes = sinon.stub().callsArgWith(2, null, { + var getBlockHashes = sinon.stub().callsArgWith(3, null, { result: [block2, block1] }); bitcoind.nodes.push({