replaced getBestBlockHash for bot method (getBlockCount + getBlockHash) to get the last block hash.
This commit is contained in:
parent
eafe7bec14
commit
ab85012bdf
|
@ -42,6 +42,13 @@ exports.show = function(req, res, next) {
|
||||||
res.jsonp(d);
|
res.jsonp(d);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if (s === 'getLastBlockHash') {
|
||||||
|
d.getLastBlockHash(function(err) {
|
||||||
|
if (err) next(err);
|
||||||
|
res.jsonp(d);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
res.status(400).send('Bad Request');
|
res.status(400).send('Bad Request');
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ function spec() {
|
||||||
this.difficulty = {};
|
this.difficulty = {};
|
||||||
this.txoutsetinfo = {};
|
this.txoutsetinfo = {};
|
||||||
this.bestblockhash = {};
|
this.bestblockhash = {};
|
||||||
|
this.lastblockhash = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Status.prototype.getInfo = function(next) {
|
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;
|
return Status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@ angular.module('mystery.status').controller('StatusController', ['$scope', '$rou
|
||||||
if (q === 'getBestBlockHash') {
|
if (q === 'getBestBlockHash') {
|
||||||
$scope.bestblockhash = d.bestblockhash;
|
$scope.bestblockhash = d.bestblockhash;
|
||||||
}
|
}
|
||||||
|
if (q === 'getLastBlockHash') {
|
||||||
|
$scope.lastblockhash = d.lastblockhash;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -127,14 +127,14 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<h3>getBestBlockHash</h3>
|
<h3>getLastBlockHash</h3>
|
||||||
<table class="table table-striped" data-ng-init="getData('getBestBlockHash')">
|
<table class="table table-striped" data-ng-init="getData('getLastBlockHash')">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr data-ng-show="!bestblockhash">
|
<tr data-ng-show="!lastblockhash">
|
||||||
<td colspan="1" class="text-center">Loading...</td>
|
<td colspan="1" class="text-center">Loading...</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{bestblockhash}}</td>
|
<td>{{lastblockhash}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -60,6 +60,16 @@ describe('Status', function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('getLastBlockHash', function(done) {
|
||||||
|
var d = new Status();
|
||||||
|
|
||||||
|
d.getLastBlockHash(function(err) {
|
||||||
|
if (err) done(err);
|
||||||
|
assert.equal('string', typeof d.lastblockhash);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue