From b7c280a84ced80f4629b6559d831e55ac84b292d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 26 Jul 2016 02:18:40 -0700 Subject: [PATCH] bip151: minor refactor. --- lib/bcoin/bip151.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/bcoin/bip151.js b/lib/bcoin/bip151.js index 40348ba4..cf5b4201 100644 --- a/lib/bcoin/bip151.js +++ b/lib/bcoin/bip151.js @@ -85,7 +85,7 @@ BIP151Stream.prototype.maybeRekey = function maybeRekey(data) { if (now >= this.lastRekey + 10 || this.processed >= this.highWaterMark) { - this.lastRekey = utils.now(); + this.lastRekey = now; this.processed = 0; this.emit('rekey'); this.rekey(); @@ -349,13 +349,11 @@ BIP151.prototype.encinit = function encinit(data) { var cipher = p.readU8(); assert(!this.initReceived, 'Already initialized.'); + this.initReceived = true; + assert(cipher === this.output.cipher, 'Cipher mismatch.'); this.output.init(publicKey); - - this.initReceived = true; - - return this; }; BIP151.prototype.toEncack = function toEncack(writer) {