From 3512cf2f23bea08f08e4a8f76eef928eb6953659 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Fri, 29 Jul 2016 16:24:03 -0300 Subject: [PATCH] blockchain height endpoint --- lib/blockchainexplorers/insight.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/blockchainexplorers/insight.js b/lib/blockchainexplorers/insight.js index 121dd49..4ae1ef3 100644 --- a/lib/blockchainexplorers/insight.js +++ b/lib/blockchainexplorers/insight.js @@ -162,6 +162,20 @@ Insight.prototype.estimateFee = function(nbBlocks, cb) { }); }; +Insight.prototype.getBlockchainHeight = function(cb) { + var path = this.apiPrefix + '/sync'; + + var args = { + method: 'GET', + path: path, + json: true, + }; + this._doRequest(args, function(err, res, body) { + if (err || res.statusCode !== 200) return cb(_parseErr(err, res)); + return cb(null, body.blockChainHeight); + }); +}; + Insight.prototype.initSocket = function() { // sockets always use the first server on the pull