diff --git a/lib/services/block/index.js b/lib/services/block/index.js index 72f9ed25..c16678db 100644 --- a/lib/services/block/index.js +++ b/lib/services/block/index.js @@ -181,9 +181,19 @@ BlockService.prototype.getRawBlock = function(hash, callback) { if(err) { return callback(err); } - let block_raw = block.toRaw(); - let block_raw_str_hex = block_raw.toString('hex'); - if (!block || typeof block_raw == "undefined" || typeof block_raw_str_hex == "undefined" || block_raw_str_hex == '') { + try{ + if(!block){ + return callback(); + } + let block_raw = block.toRaw(); + if(typeof block_raw == "undefined" || !block_raw){ + return callback(); + } + let block_raw_str_hex = block_raw.toString('hex'); + if(typeof block_raw_str_hex == "undefined" || block_raw_str_hex == ''){ + return callback(); + } + } catch(e){ return callback(); } log.info("Testing getRawBlock " + block_raw_str_hex);