diff --git a/lib/bcoin/bip151.js b/lib/bcoin/bip151.js index 2482dc99..4054c7b5 100644 --- a/lib/bcoin/bip151.js +++ b/lib/bcoin/bip151.js @@ -83,10 +83,10 @@ BIP151Stream.prototype.maybeRekey = function maybeRekey(data) { this.processed += data.length; - if (now > this.lastRekey + 10 + if (now >= this.lastRekey + 10 || this.processed >= this.highWaterMark) { this.lastRekey = utils.now(); - this.processed -= this.highWaterMark; + this.processed = 0; this.emit('rekey'); this.rekey(); }