From b2d4e3c327c4c012e46fd2c7c7172e06c3dd6a2e Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Wed, 15 Jan 2014 18:27:06 -0300 Subject: [PATCH] added getbestblockhash to Status class --- app/models/Status.js | 17 +++++++++++++++++ test/model/status.js | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/models/Status.js b/app/models/Status.js index be5149c..fab5fff 100644 --- a/app/models/Status.js +++ b/app/models/Status.js @@ -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; } diff --git a/test/model/status.js b/test/model/status.js index 0795ecb..599d701 100644 --- a/test/model/status.js +++ b/test/model/status.js @@ -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(); + }); + }); + + });