Merge pull request #83 from cmgustavo/feature/03status
refactory: status controller: Great!
This commit is contained in:
commit
72741f88fb
@ -15,43 +15,34 @@ exports.show = function(req, res, next) {
|
|||||||
res.status(400).send('Bad Request');
|
res.status(400).send('Bad Request');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var s = req.query.q;
|
var option = req.query.q;
|
||||||
var d = Status.new();
|
var statusObject = Status.new();
|
||||||
|
|
||||||
if (s === 'getInfo') {
|
var returnJsonp = function (err) {
|
||||||
d.getInfo(function(err) {
|
if(err) return next(err);
|
||||||
if (err) next(err);
|
res.jsonp(statusObject);
|
||||||
res.jsonp(d);
|
};
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (s === 'getDifficulty') {
|
|
||||||
d.getDifficulty(function(err) {
|
|
||||||
if (err) next(err);
|
|
||||||
res.jsonp(d);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (s === 'getTxOutSetInfo') {
|
|
||||||
d.getTxOutSetInfo(function(err) {
|
|
||||||
if (err) next(err);
|
|
||||||
res.jsonp(d);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (s === 'getBestBlockHash') {
|
|
||||||
d.getBestBlockHash(function(err) {
|
|
||||||
if (err) next(err);
|
|
||||||
res.jsonp(d);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (s === 'getLastBlockHash') {
|
|
||||||
d.getLastBlockHash(function(err) {
|
|
||||||
if (err) next(err);
|
|
||||||
res.jsonp(d);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
switch(option) {
|
||||||
res.status(400).send('Bad Request');
|
case 'getInfo':
|
||||||
|
statusObject.getInfo(returnJsonp);
|
||||||
|
break;
|
||||||
|
case 'getDifficulty':
|
||||||
|
statusObject.getDifficulty(returnJsonp);
|
||||||
|
break;
|
||||||
|
case 'getTxOutSetInfo':
|
||||||
|
statusObject.getTxOutSetInfo(returnJsonp);
|
||||||
|
break;
|
||||||
|
case 'getBestBlockHash':
|
||||||
|
statusObject.getBestBlockHash(returnJsonp);
|
||||||
|
break;
|
||||||
|
case 'getLastBlockHash':
|
||||||
|
statusObject.getLastBlockHash(returnJsonp);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.status(400).send('Bad Request');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user