Fixed: crashing when unknown block

This commit is contained in:
Sai Raj 2023-01-06 23:02:07 +05:30 committed by GitHub
parent 0a52cc93db
commit 97d7c6ecde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);