From 39a4df7b0220c7e71a0a12a4be5ff9614f04f0f1 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 17 Nov 2016 05:02:26 -0800 Subject: [PATCH] peer: improve sendcmpct handling. --- lib/net/peer.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/net/peer.js b/lib/net/peer.js index 1f5ca591..cc1b7a37 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -2124,7 +2124,9 @@ Peer.prototype._handleUnknown = function _handleUnknown(packet) { */ Peer.prototype._handleSendCmpct = function _handleSendCmpct(packet) { - if (packet.version > 2) { + var max = this.options.witness ? 2 : 1; + + if (packet.version > max) { // Ignore this.logger.info('Peer request compact blocks version %d (%s).', packet.version, this.hostname); @@ -2137,6 +2139,13 @@ Peer.prototype._handleSendCmpct = function _handleSendCmpct(packet) { return; } + // Core witness nodes send this twice + // with both version 1 and 2 (why + // would you even _want_ non-witness + // blocks if you use segwit??). + if (this.compactMode) + return; + this.logger.info('Peer initialized compact blocks (%s).', this.hostname); this.compactMode = packet;