Merge pull request #77 from cubedro/develop

added workaround for cpp getBlock #60000 problem
This commit is contained in:
Marian OANCΞA 2015-04-17 00:14:44 +03:00
commit 3909772333
1 changed files with 13 additions and 2 deletions

View File

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