Don't crash on Genesis block search
This commit is contained in:
parent
996b85883e
commit
5a1ebc74c0
@ -62,6 +62,12 @@ BlockController.prototype.checkBlockHash = function(req, res, next) {
|
||||
BlockController.prototype.block = function(req, res, next) {
|
||||
var self = this;
|
||||
var hash = req.params.blockHash;
|
||||
|
||||
// Searching Genesis block crashes server
|
||||
// Tmp handle by returning no block in index
|
||||
if (hash === "0" || hash === 0)
|
||||
return self.common.handleErrors(new Error('block not in index'), res);
|
||||
|
||||
var blockCached = self.blockCache.get(hash);
|
||||
|
||||
if (blockCached) {
|
||||
@ -73,9 +79,7 @@ BlockController.prototype.block = function(req, res, next) {
|
||||
self._block.getBlock(hash, function(err, block) {
|
||||
if (err) {
|
||||
return self.common.handleErrors(err, res);
|
||||
}
|
||||
|
||||
if (!block) {
|
||||
} else if (!block) {
|
||||
return self.common.handleErrors(new Error('block not in index'), res);
|
||||
}
|
||||
|
||||
|
||||
@ -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.64",
|
||||
"version": "5.0.0-beta.65",
|
||||
"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