pool: disable bip37 by default.

This commit is contained in:
Christopher Jeffrey 2017-01-23 15:01:55 -08:00
parent c6b439f21c
commit 2a6ee729a0
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
5 changed files with 35 additions and 4 deletions

View File

@ -53,6 +53,7 @@ replace-by-fee: false
selfish: false
compact: true
bip37: false
bip151: true
listen: true
max-outbound: 8

View File

@ -105,7 +105,6 @@ exports.services = {
exports.LOCAL_SERVICES = 0
| exports.services.NETWORK
| exports.services.BLOOM
| exports.services.WITNESS;
/**

View File

@ -1527,6 +1527,14 @@ Pool.prototype.handleGetData = co(function* handleGetData(peer, packet) {
break;
case invTypes.FILTERED_BLOCK:
case invTypes.WITNESS_FILTERED_BLOCK:
if (!this.options.bip37) {
this.logger.debug(
'Peer requested a merkleblock without bip37 enabled (%s).',
peer.hostname());
peer.destroy();
return;
}
if (!peer.spvFilter) {
notFound.push(item);
continue;
@ -2188,6 +2196,14 @@ Pool.prototype.handleMempool = co(function* handleMempool(peer, packet) {
if (this.options.selfish)
return;
if (!this.options.bip37) {
this.logger.debug(
'Peer requested mempool without bip37 enabled (%s).',
peer.hostname());
peer.destroy();
return;
}
hashes = this.mempool.getSnapshot();
for (i = 0; i < hashes.length; i++) {
@ -3194,8 +3210,9 @@ function PoolOptions(options) {
this.checkpoints = true;
this.spv = false;
this.bip37 = false;
this.listen = false;
this.compact = false;
this.compact = true;
this.noRelay = false;
this.host = '0.0.0.0';
this.port = this.network.port;
@ -3272,6 +3289,11 @@ PoolOptions.prototype.fromOptions = function fromOptions(options) {
this.spv = this.chain.options.spv;
}
if (options.bip37 != null) {
assert(typeof options.bip37 === 'boolean');
this.bip37 = options.bip37;
}
if (options.listen != null) {
assert(typeof options.listen === 'boolean');
this.listen = options.listen;
@ -3426,10 +3448,17 @@ PoolOptions.prototype.fromOptions = function fromOptions(options) {
this.services &= ~common.services.NETWORK;
this.noRelay = true;
this.checkpoints = true;
this.compact = false;
this.bip37 = false;
}
if (this.selfish)
if (this.selfish) {
this.services &= ~common.services.NETWORK;
this.bip37 = false;
}
if (this.bip37)
this.services |= common.services.BLOOM;
if (options.services != null) {
assert(util.isUInt32(options.services));
@ -3484,7 +3513,7 @@ PoolOptions.prototype.isFull = function isFull() {
*/
PoolOptions.prototype.getRequiredServices = function getRequiredServices() {
var services = this.options.requiredServices;
var services = this.requiredServices;
if (this.hasWitness())
services |= common.services.WITNESS;
return services;

View File

@ -188,6 +188,7 @@ config.parseData = function parseData(data, prefix, dirname) {
// Pool
options.selfish = bool(data.selfish);
options.compact = bool(data.compact);
options.bip37 = bool(data.bip37);
options.bip151 = bool(data.bip151);
options.bip150 = bool(data.bip150);
options.identityKey = key(data.identitykey);

View File

@ -102,6 +102,7 @@ function FullNode(options) {
mempool: this.mempool,
selfish: this.options.selfish,
compact: this.options.compact,
bip37: this.options.bip37,
bip151: this.options.bip151,
bip150: this.options.bip150,
authPeers: this.options.authPeers,