peer: improve sendcmpct handling.

This commit is contained in:
Christopher Jeffrey 2016-11-17 05:02:26 -08:00
parent d3da8bbfb8
commit 39a4df7b02
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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;