From b48bd95c8bb624b963a8d3ca9cbc2e5ee52b0bdb Mon Sep 17 00:00:00 2001 From: MineMoneroPRO Date: Fri, 10 Nov 2017 00:18:47 +0300 Subject: [PATCH] Update local_comms.js fix for #145 --- lib/local_comms.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 5955893..4d0b213 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -581,12 +581,16 @@ function Database(){ let oldestLockedBlock = this.getOldestLockedBlock(); async.waterfall([ function(callback){ - global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { - oldestLockedBlock.height = result.height; - console.log(`Got the oldest block`); - callback(null, oldestLockedBlock); - }); - }, + if (oldestLockedBlock === null) { + callback(null, oldestLockedBlock) + } else { + global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { + oldestLockedBlock.height = result.height; + console.log(Got the oldest block); + callback(null, oldestLockedBlock); + }); + } + }, function(oldestLockedBlock, callback){ global.coinFuncs.getLastBlockHeader(function(err, body){ if (oldestLockedBlock === null){ @@ -691,4 +695,4 @@ function Database(){ }, 900000); // Set DB env reload for every 15 minutes. } -module.exports = Database; \ No newline at end of file +module.exports = Database;