diff --git a/app/controllers/status.js b/app/controllers/status.js index 47b1f450..eb2f1ae3 100644 --- a/app/controllers/status.js +++ b/app/controllers/status.js @@ -42,6 +42,13 @@ exports.show = function(req, res, next) { res.jsonp(d); }); } + else if (s === 'getLastBlockHash') { + d.getLastBlockHash(function(err) { + if (err) next(err); + res.jsonp(d); + }); + } + else { res.status(400).send('Bad Request'); } diff --git a/app/models/Status.js b/app/models/Status.js index fab5fffd..9ab66785 100644 --- a/app/models/Status.js +++ b/app/models/Status.js @@ -13,6 +13,7 @@ function spec() { this.difficulty = {}; this.txoutsetinfo = {}; this.bestblockhash = {}; + this.lastblockhash = {}; } Status.prototype.getInfo = function(next) { @@ -79,6 +80,31 @@ function spec() { }); }; + Status.prototype.getLastBlockHash = function(next) { + var that = this; + + async.waterfall( + [ + function(callback){ + rpc.getBlockCount(function(err, bc){ + if (err) return callback(err); + callback(null, bc.result); + }); + }, + function(bc, callback){ + rpc.getBlockHash(bc, function(err, bh){ + if (err) return callback(err); + callback(null, bh.result); + }); + } + ], + function (err, result) { + that.lastblockhash = result; + return next(); + } + ); + }; + return Status; } diff --git a/public/js/controllers/status.js b/public/js/controllers/status.js index cc02da9e..e219cecd 100644 --- a/public/js/controllers/status.js +++ b/public/js/controllers/status.js @@ -19,6 +19,10 @@ angular.module('mystery.status').controller('StatusController', ['$scope', '$rou if (q === 'getBestBlockHash') { $scope.bestblockhash = d.bestblockhash; } + if (q === 'getLastBlockHash') { + $scope.lastblockhash = d.lastblockhash; + } + }); }; diff --git a/public/views/status.html b/public/views/status.html index f28e0e40..9009f920 100644 --- a/public/views/status.html +++ b/public/views/status.html @@ -127,14 +127,14 @@
Loading... | |
{{bestblockhash}} | +{{lastblockhash}} |