From 1373ad9b046c784e7e0a9e49a443fcd45c82f1b0 Mon Sep 17 00:00:00 2001 From: cubedro Date: Fri, 17 Apr 2015 00:14:12 +0300 Subject: [PATCH] added workaround for cpp getBlock #60000 problem --- lib/node.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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)