diff --git a/lib/bcoin/bip151.js b/lib/bcoin/bip151.js index 8ae277c8..a904742d 100644 --- a/lib/bcoin/bip151.js +++ b/lib/bcoin/bip151.js @@ -79,7 +79,7 @@ function BIP151Stream(cipher, key) { this.lastRekey = 0; this.pending = []; - this.pendingTotal = 0; + this.total = 0; this.waiting = 0; } @@ -277,15 +277,15 @@ BIP151Stream.prototype.feed = function feed(data) { while (data.length) { if (!this.waiting) { - this.pendingTotal += data.length; + this.total += data.length; this.pending.push(data); - if (this.pendingTotal < 4) + if (this.total < 4) break; chunk = concat(this.pending); - this.pendingTotal = 0; + this.total = 0; this.pending.length = 0; size = this.decryptSize(chunk); @@ -307,10 +307,10 @@ BIP151Stream.prototype.feed = function feed(data) { continue; } - this.pendingTotal += data.length; + this.total += data.length; this.pending.push(data); - if (this.pendingTotal < this.waiting) + if (this.total < this.waiting) break; chunk = concat(this.pending); @@ -318,7 +318,7 @@ BIP151Stream.prototype.feed = function feed(data) { tag = chunk.slice(this.waiting - 16, this.waiting); data = chunk.slice(this.waiting); - this.pendingTotal = 0; + this.total = 0; this.pending.length = 0; this.waiting = 0; diff --git a/lib/bcoin/protocol/parser.js b/lib/bcoin/protocol/parser.js index d7f335e4..89a2cddf 100644 --- a/lib/bcoin/protocol/parser.js +++ b/lib/bcoin/protocol/parser.js @@ -36,7 +36,7 @@ function Parser(options) { this.bip151 = options.bip151; this.pending = []; - this.pendingTotal = 0; + this.total = 0; this.waiting = 24; this.packet = null; @@ -89,10 +89,10 @@ Parser.prototype.feed = function feed(data) { if (this.bip151 && this.bip151.handshake) return this.bip151.feed(data); - this.pendingTotal += data.length; + this.total += data.length; this.pending.push(data); - while (this.pendingTotal >= this.waiting) { + while (this.total >= this.waiting) { // Concat chunks chunk = new Buffer(this.waiting); @@ -111,7 +111,7 @@ Parser.prototype.feed = function feed(data) { assert.equal(off, chunk.length); // Slice buffers - this.pendingTotal -= chunk.length; + this.total -= chunk.length; this.parse(chunk); } }; diff --git a/lib/bcoin/workers.js b/lib/bcoin/workers.js index 9b9fb940..f00a27b4 100644 --- a/lib/bcoin/workers.js +++ b/lib/bcoin/workers.js @@ -945,7 +945,7 @@ function Parser() { this.waiting = 12; this.header = null; this.pending = []; - this.pendingTotal = 0; + this.total = 0; } utils.inherits(Parser, EventEmitter); @@ -954,11 +954,11 @@ Parser.prototype.feed = function feed(data) { var chunk, header, body; while (data) { - this.pendingTotal += data.length; + this.total += data.length; this.pending.push(data); data = null; - if (this.pendingTotal < this.waiting) + if (this.total < this.waiting) break; chunk = concat(this.pending); @@ -972,7 +972,7 @@ Parser.prototype.feed = function feed(data) { this.header = this.parseHeader(chunk); this.waiting = this.header.size; this.pending.length = 0; - this.pendingTotal = 0; + this.total = 0; if (this.header.magic !== 0xdeadbeef) { this.header = null; @@ -987,7 +987,7 @@ Parser.prototype.feed = function feed(data) { header = this.header; this.pending.length = 0; - this.pendingTotal = 0; + this.total = 0; this.waiting = 12; this.header = null;