services.
This commit is contained in:
parent
5ac4621b0e
commit
a5b8da17fc
@ -939,14 +939,17 @@ Peer.prototype._handleGetBlocks = function _handleGetBlocks(payload) {
|
||||
};
|
||||
|
||||
Peer.prototype._handleVersion = function handleVersion(payload) {
|
||||
if (payload.version < constants.MIN_VERSION) {
|
||||
var version = payload.version;
|
||||
var services = payload.services;
|
||||
|
||||
if (version < constants.MIN_VERSION) {
|
||||
this._error('Peer doesn\'t support required protocol version.');
|
||||
this.setMisbehavior(100);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.options.headers) {
|
||||
if (payload.version < 31800) {
|
||||
if (version < 31800) {
|
||||
this._error('Peer doesn\'t support getheaders.');
|
||||
this.setMisbehavior(100);
|
||||
return;
|
||||
@ -954,7 +957,7 @@ Peer.prototype._handleVersion = function handleVersion(payload) {
|
||||
}
|
||||
|
||||
if (this.options.network) {
|
||||
if (!payload.network) {
|
||||
if (!(services & constants.services.NETWORK)) {
|
||||
this._error('Peer does not support network services.');
|
||||
this.setMisbehavior(100);
|
||||
return;
|
||||
@ -962,7 +965,7 @@ Peer.prototype._handleVersion = function handleVersion(payload) {
|
||||
}
|
||||
|
||||
if (this.options.spv) {
|
||||
if (!payload.bloom && payload.version < 70011) {
|
||||
if (version < 70011 || !(services & constants.services.BLOOM)) {
|
||||
this._error('Peer does not support bip37.');
|
||||
this.setMisbehavior(100);
|
||||
return;
|
||||
@ -970,12 +973,11 @@ Peer.prototype._handleVersion = function handleVersion(payload) {
|
||||
}
|
||||
|
||||
if (this.options.witness) {
|
||||
if (!payload.witness) {
|
||||
if (!(services & constants.services.WITNESS)) {
|
||||
this._req('havewitness', function(err) {
|
||||
if (err) {
|
||||
self._error('Peer does not support segregated witness.');
|
||||
self.setMisbehavior(100);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1210,16 +1212,11 @@ Peer.prototype._handleAddr = function handleAddr(addrs) {
|
||||
ts = now - 5 * 24 * 60 * 60;
|
||||
|
||||
this.emit('addr', {
|
||||
version: addr.version,
|
||||
ts: ts,
|
||||
services: addr.services,
|
||||
host: host,
|
||||
port: addr.port || this.network.port,
|
||||
network: addr.network,
|
||||
bloom: addr.bloom,
|
||||
getutxo: addr.getutxo,
|
||||
witness: addr.witness,
|
||||
headers: addr.version >= 31800,
|
||||
spv: addr.bloom && addr.version >= 70011
|
||||
port: addr.port || this.network.port
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -954,14 +954,23 @@ Pool.prototype._createPeer = function _createPeer(options) {
|
||||
if (self.options.discoverPeers === false)
|
||||
return;
|
||||
|
||||
if (!data.network)
|
||||
if (!(data.services & constants.services.NETWORK))
|
||||
return;
|
||||
|
||||
if (self.options.spv && !data.spv)
|
||||
return;
|
||||
if (self.options.headers) {
|
||||
if (data.version < 31800)
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.options.witness && !data.witness)
|
||||
return;
|
||||
if (self.options.spv) {
|
||||
if (data.version < 70011 || !(data.services & constants.services.BLOOM))
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.options.witness) {
|
||||
if (!(data.services & constants.services.WITNESS))
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.seeds.length > 300)
|
||||
self.setSeeds(self.seeds.slice(-150));
|
||||
|
||||
@ -485,10 +485,6 @@ Parser.parseVersion = function parseVersion(p) {
|
||||
return {
|
||||
version: version,
|
||||
services: services,
|
||||
network: (services & constants.services.NETWORK) !== 0,
|
||||
getutxo: (services & constants.services.GETUTXO) !== 0,
|
||||
bloom: (services & constants.services.BLOOM) !== 0,
|
||||
witness: (services & constants.services.WITNESS) !== 0,
|
||||
ts: ts,
|
||||
local: recv,
|
||||
remote: from,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user