fix getInfo. new method getDifficulty
This commit is contained in:
parent
5ddddb520d
commit
80f438fbc5
@ -10,16 +10,33 @@ function spec() {
|
|||||||
|
|
||||||
function Status() {
|
function Status() {
|
||||||
this.info = {};
|
this.info = {};
|
||||||
|
this.difficulty = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Status.prototype.getInfo = function(next) {
|
Status.prototype.getInfo = function(next) {
|
||||||
var that = this;
|
var that = this;
|
||||||
async.series([
|
async.series([
|
||||||
function (cb) {
|
function (cb) {
|
||||||
rpc.getInfo(function(err, block){
|
rpc.getInfo(function(err, info){
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
that.info = block.result;
|
that.info = info.result;
|
||||||
|
return cb();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], function (err) {
|
||||||
|
return next(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Status.prototype.getDifficulty = function(next) {
|
||||||
|
var that = this;
|
||||||
|
async.series([
|
||||||
|
function (cb) {
|
||||||
|
rpc.getDifficulty(function(err, df){
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
that.difficulty = df.result;
|
||||||
return cb();
|
return cb();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,17 @@ describe('Status', function(){
|
|||||||
|
|
||||||
d.getInfo(function(err) {
|
d.getInfo(function(err) {
|
||||||
if (err) done(err);
|
if (err) done(err);
|
||||||
assert.equal(4096, d.info.difficulty);
|
assert.equal('number', typeof d.info.difficulty);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getDifficulty', function(done) {
|
||||||
|
var d = new Status();
|
||||||
|
|
||||||
|
d.getDifficulty(function(err) {
|
||||||
|
if (err) done(err);
|
||||||
|
assert.equal('number', typeof d.difficulty);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user