diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index a3887899..303f2c10 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -1603,13 +1603,12 @@ Chain.prototype.verifyCheckpoint = function verifyCheckpoint(prev, hash) { */ Chain.prototype.storeOrphan = function storeOrphan(block, flags, id) { - const hash = block.hash('hex'); const height = block.getCoinbaseHeight(); - let orphan = this.orphanPrev.get(block.prevBlock); + const orphan = this.orphanPrev.get(block.prevBlock); // The orphan chain forked. if (orphan) { - assert(orphan.block.hash('hex') !== hash); + assert(orphan.block.hash('hex') !== block.hash('hex')); assert(orphan.block.prevBlock === block.prevBlock); this.logger.warning( @@ -1620,10 +1619,7 @@ Chain.prototype.storeOrphan = function storeOrphan(block, flags, id) { } this.limitOrphans(); - - orphan = new Orphan(block, flags, id); - - this.addOrphan(orphan); + this.addOrphan(new Orphan(block, flags, id)); this.logger.debug( 'Storing orphan block: %s (%d).', diff --git a/lib/utils/util.js b/lib/utils/util.js index ffe898ef..f348c437 100644 --- a/lib/utils/util.js +++ b/lib/utils/util.js @@ -850,10 +850,12 @@ util.toFixed = function toFixed(num, exp) { } const mult = pow10(exp); + let lo = num % mult; - const hi = (num - lo) / mult; + let hi = (num - lo) / mult; lo = lo.toString(10); + hi = hi.toString(10); while (lo.length < exp) lo = '0' + lo;