added getbestblockhash to Status class

This commit is contained in:
Gustavo Cortez 2014-01-15 18:27:06 -03:00
parent c96b6a7598
commit b2d4e3c327
2 changed files with 28 additions and 0 deletions

View File

@ -12,6 +12,7 @@ function spec() {
this.info = {};
this.difficulty = {};
this.txoutsetinfo = {};
this.bestblockhash = {};
}
Status.prototype.getInfo = function(next) {
@ -62,6 +63,22 @@ function spec() {
});
};
Status.prototype.getBestBlockHash = function(next) {
var that = this;
async.series([
function (cb) {
rpc.getBestBlockHash(function(err, bbh){
if (err) return cb(err);
that.bestblockhash = bbh.result;
return cb();
});
}
], function (err) {
return next(err);
});
};
return Status;
}

View File

@ -50,5 +50,16 @@ describe('Status', function(){
});
});
it('getBestBlockHash', function(done) {
var d = new Status();
d.getBestBlockHash(function(err) {
if (err) done(err);
assert.equal('string', typeof d.bestblockhash);
done();
});
});
});