From c71e7646d3b488f5f54ea453f9a7989559945c66 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 22 May 2016 17:33:38 -0700 Subject: [PATCH] fix readvarint2. fix memUsage. --- lib/bcoin/mempool.js | 2 +- lib/bcoin/miner.js | 4 ++-- lib/bcoin/utils.js | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bcoin/mempool.js b/lib/bcoin/mempool.js index fd094f3c..a3232b37 100644 --- a/lib/bcoin/mempool.js +++ b/lib/bcoin/mempool.js @@ -1729,7 +1729,7 @@ Mempool.prototype.memUsageBitcoind = function memUsageBitcoind(tx) { input = tx.inputs[i]; mem += mallocUsage(input.witness.items.length); for (j = 0; j < input.witness.items.length; j++) - mem += mallocUsage(input.witness[j].items.length); + mem += mallocUsage(input.witness.items[j].length); } return mem; diff --git a/lib/bcoin/miner.js b/lib/bcoin/miner.js index 32d0559c..53c52fb6 100644 --- a/lib/bcoin/miner.js +++ b/lib/bcoin/miner.js @@ -570,14 +570,14 @@ MinerBlock.prototype.findNonce = function findNonce() { MinerBlock.prototype.__defineGetter__('hashes', function() { return new bn(this.iterations) .mul(utils.U32) - .addn(this.block.nonce); + .addn(this.block.nonce | 0); }); MinerBlock.prototype.__defineGetter__('rate', function() { if (!this.block.nonce) return 0; // Calculate our terrible hashrate - return (this.block.nonce / (utils.now() - this.begin)) * 2 | 0; + return (this.block.nonce / (utils.now() - this.begin)) | 0; }); /** diff --git a/lib/bcoin/utils.js b/lib/bcoin/utils.js index 6850aa09..6674e3bc 100644 --- a/lib/bcoin/utils.js +++ b/lib/bcoin/utils.js @@ -1838,6 +1838,7 @@ utils.readVarint2 = function readVarint2(data, off, big) { if (num >= 0x3fffffffffff) { assert(big, 'Number exceeds 2^53-1.'); bnum = new bn(num); + num = 0; } if (bnum) {