blocks: switch to use req.param

so that the last argument is the next callback
This commit is contained in:
Braydon Fuller 2016-05-10 16:50:28 -04:00
parent 310dd99086
commit 7973e2398a
2 changed files with 26 additions and 12 deletions

View File

@ -35,9 +35,9 @@ BlockController.DEFAULT_BLOCK_CACHE_SIZE = 1000;
/**
* Find block by hash ...
*/
BlockController.prototype.block = function(req, res, next, hash) {
BlockController.prototype.block = function(req, res, next) {
var self = this;
var hash = req.params.blockHash;
var blockCached = self.blockCache.get(hash);
if (blockCached) {
@ -69,8 +69,9 @@ BlockController.prototype.block = function(req, res, next, hash) {
/**
* Find rawblock by hash and height...
*/
BlockController.prototype.rawBlock = function(req, res, next, blockArg) {
BlockController.prototype.rawBlock = function(req, res, next) {
var self = this;
var blockArg = req.params.blockArg;
self.node.getRawBlock(blockArg, function(err, blockBuffer) {
if(err && err.code === -5) {
@ -136,7 +137,8 @@ BlockController.prototype.showRaw = function(req, res) {
}
};
BlockController.prototype.blockIndex = function(req, res, next, height) {
BlockController.prototype.blockIndex = function(req, res) {
var height = req.params.height;
this.node.services.bitcoind.getBlockHeader(parseInt(height), function(err, info) {
if (err) {
return common.handleErrors(err, res);

View File

@ -84,7 +84,11 @@ describe('Blocks', function() {
it('block data should be correct', function(done) {
var controller = new BlockController({node: node});
var req = {};
var req = {
params: {
blockHash: hash
}
};
var res = {};
var next = function() {
should.exist(req.block);
@ -95,7 +99,7 @@ describe('Blocks', function() {
var hash = '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7';
controller.block(req, res, next, hash);
controller.block(req, res, next);
});
it('block pool info should be correct', function(done) {
@ -111,7 +115,11 @@ describe('Blocks', function() {
}
};
var controller = new BlockController({node: node});
var req = {};
var req = {
params: {
blockHash: hash
}
};
var res = {};
var next = function() {
should.exist(req.block);
@ -123,7 +131,7 @@ describe('Blocks', function() {
var hash = '000000000000000004a118407a4e3556ae2d5e882017e7ce526659d8073f13a4';
controller.block(req, res, next, hash);
controller.block(req, res, next);
});
});
@ -225,17 +233,21 @@ describe('Blocks', function() {
'blockHash': '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7'
};
var req = {};
var height = 533974;
var req = {
params: {
height: height
}
};
var res = {
jsonp: function(data) {
should(data).eql(insight);
done();
}
};
var next = function() {};
var height = 533974;
blocks.blockIndex(req, res, next, height);
blocks.blockIndex(req, res);
});
});