promisify Blocks.getLatest
This commit is contained in:
parent
591f28f56b
commit
a09f939b02
@ -54,14 +54,18 @@ Blocks.heightParam = function(req, res, next, height) {
|
||||
*/
|
||||
|
||||
Blocks.getLatest = function(req, res) {
|
||||
req.block = node.getLatestBlock();
|
||||
Blocks.get(req, res);
|
||||
node.getLatestBlock()
|
||||
.then(function(block) {
|
||||
req.block = block;
|
||||
Blocks.get(req, res);
|
||||
});
|
||||
};
|
||||
|
||||
Blocks.get = function(req, res) {
|
||||
$.checkState(req.block instanceof Block);
|
||||
res.send(req.block.toObject());
|
||||
};
|
||||
|
||||
Blocks.getBlockError = function(req, res) {
|
||||
res.status(422);
|
||||
res.send('/v1/blocks/ parameter must be a 64 digit hex or block height integer');
|
||||
|
||||
@ -37,7 +37,7 @@ describe('BitcoreHTTP v1 blocks routes', function() {
|
||||
|
||||
};
|
||||
nodeMock.getLatestBlock = function() {
|
||||
return mockBlocks[Object.keys(mockBlocks).splice(-1)[0]];
|
||||
return Promise.resolve(mockBlocks[Object.keys(mockBlocks).splice(-1)[0]]);
|
||||
};
|
||||
app = new BitcoreHTTP(nodeMock).app;
|
||||
agent = request(app);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user