From c6e604a811489986f1be536aab58e79c9dc6cf81 Mon Sep 17 00:00:00 2001 From: Michael Rodriguez Date: Fri, 8 Jun 2018 17:48:52 -0400 Subject: [PATCH 1/2] Change litecore-lib export alias from bitcore to litecore --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index f786386..2a97d2e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,5 @@ module.exports = { models: require('./models'), Insight: require('./insight'), - bitcore: require('litecore-lib'), + litecore: require('litecore-lib'), }; From 7d0169b4333dcf66751ff94117554265d54de586 Mon Sep 17 00:00:00 2001 From: Michael Rodriguez Date: Fri, 24 Aug 2018 21:04:50 -0400 Subject: [PATCH 2/2] Implement getBlockIndex --- lib/insight.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/insight.js b/lib/insight.js index 5c06ba1..0181fa2 100644 --- a/lib/insight.js +++ b/lib/insight.js @@ -225,6 +225,30 @@ Insight.prototype.getBlocks = function(callback) { }); }; +/** + * @callback Insight.GetBlockIndexCallback + * @param {Error} err + * @param {string} blockhash + */ + +/** + * Get block index + * @param {number} blockheight + * @param {GetBlockIndexCallback} callback + * */ +Insight.prototype.getBlockIndex = function(blockheight, callback) { + $.checkArgument(_.isFunction(callback)); + + this.requestGet('/api/block-index/' + blockheight, function(err, res, body) { + if (err || res.statusCode !== 200) { + return callback(err || res); + } + let { blockHash } = JSON.parse(body); + + return callback(null, blockHash); + }); +}; + /** * @callback Insight.GetBlockCallback * @param {Error} err