diff --git a/lib/node.js b/lib/node.js index 071caeb..b2cb029 100644 --- a/lib/node.js +++ b/lib/node.js @@ -196,8 +196,19 @@ Node.prototype.getBlock = function(number) } catch (err) { console.error("getBlock(" + number + "):", err); + if(number > 0){ + try { + number -= 1; + block = web3.eth.getBlock(number, true); - return false; + if(block.hash != '?' && typeof block.difficulty !== 'undefined') + { + block.difficulty = web3.toDecimal(block.difficulty); + } + } catch (err) { + console.error("getBlock(" + number + "):", err); + } + } } return block; @@ -358,7 +369,7 @@ Node.prototype.getStats = function() { var block = this.getBlock(); - if(block) { + if(block.hash !== '?') { this.stats.block = block; // Get last MAX_BLOCKS_HISTORY blocks for calculations if(this.stats.block.number > 0)