Add errors for block header undefined results
This commit is contained in:
parent
ad123dd415
commit
9c0f824ad7
@ -79,7 +79,8 @@ BlockController.prototype.block = function(req, res, next) {
|
||||
self._block.getBlock(hash, function(err, block) {
|
||||
if (err) {
|
||||
return self.common.handleErrors(err, res);
|
||||
} else if (!block) {
|
||||
}
|
||||
if (!block) {
|
||||
return self.common.handleErrors(new Error('block not in index'), res);
|
||||
}
|
||||
|
||||
@ -88,7 +89,16 @@ BlockController.prototype.block = function(req, res, next) {
|
||||
return self.common.handleErrors(err, res);
|
||||
}
|
||||
|
||||
if (!info) {
|
||||
return self.common.handleErrors(new Error('block header info undefined'), res)
|
||||
}
|
||||
|
||||
var blockResult = self.transformBlock(block, info);
|
||||
|
||||
if (!blockResult) {
|
||||
return self.common.handleErrors(new Error('blockResult from transformBlock undefined'), res)
|
||||
}
|
||||
|
||||
if (blockResult.confirmations >= self.blockCacheConfirmations) {
|
||||
self.blockCache.set(hash, blockResult);
|
||||
}
|
||||
@ -134,6 +144,9 @@ BlockController.prototype._normalizePrevHash = function(hash) {
|
||||
};
|
||||
|
||||
BlockController.prototype.transformBlock = function(block, info) {
|
||||
if (!block || !info){
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var transactionIds = block.txs.map(function(tx) {
|
||||
return tx.txid();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "flosight-api",
|
||||
"description": "A Florincoin blockchain REST and web socket API service for Flocore Node.",
|
||||
"version": "5.0.0-beta.66",
|
||||
"version": "5.0.0-beta.67",
|
||||
"repository": "git://github.com/bitpay/flosight-api.git",
|
||||
"bugs": {
|
||||
"url": "https://github.com/bitpay/flosight-api/issues"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user