bip151: minor.

This commit is contained in:
Christopher Jeffrey 2016-09-16 19:26:24 -07:00
parent d6576c51f1
commit 58a5372b09
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -31,7 +31,7 @@ var HKDF_SALT = new Buffer('bitcoinecdh', 'ascii');
var INFO_KEY1 = new Buffer('BitcoinK1', 'ascii');
var INFO_KEY2 = new Buffer('BitcoinK2', 'ascii');
var INFO_SID = new Buffer('BitcoinSessionID', 'ascii');
var HIGH_WATER_MARK = 1024 * (1 << 20);
var HIGH_WATERMARK = 1024 * (1 << 20);
/**
* Represents a BIP151 input or output stream.
@ -122,7 +122,7 @@ BIP151Stream.prototype.shouldRekey = function shouldRekey(data) {
this.processed += data.length;
if (now >= this.lastRekey + 10
|| this.processed >= HIGH_WATER_MARK) {
|| this.processed >= HIGH_WATERMARK) {
this.lastRekey = now;
this.processed = 0;
return true;
@ -408,11 +408,14 @@ BIP151.prototype.encack = function encack(publicKey) {
if (utils.equal(publicKey, constants.ZERO_KEY)) {
assert(this.handshake, 'No initialization before rekey.');
if (this.bip150 && this.bip150.auth) {
this.bip150.rekeyInput();
return;
}
this.input.rekey();
return;
}
@ -615,10 +618,10 @@ BIP151.prototype.parse = function parse(data) {
// from buffering tons of data due to either an
// potential dos'er or a cipher state mismatch.
// Note that 6 is the minimum size:
// varinti-clen(1) string-cmd(1) uint32-size(4) data(0)
// varint-cmdlen(1) str-cmd(1) u32-size(4) payload(0)
if (size < 6 || size > constants.MAX_MESSAGE * 3) {
this.waiting = 4;
this.error('Bad packet size.');
this.error('Bad packet size: %d.', utils.mb(size));
return;
}
@ -642,7 +645,7 @@ BIP151.prototype.parse = function parse(data) {
if (!this.input.verify(tag)) {
this.input.sequence();
this.error('Bad tag.');
this.error('Bad tag: %s.', tag.toString('hex'));
return;
}