From a6dc5a08c80fb0864a81b8cf214fea21a966b9d7 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 12 Jul 2016 15:34:41 -0700 Subject: [PATCH] misc. fix rejects filter additions. --- lib/bcoin/fullnode.js | 4 +++- lib/bcoin/http/client.js | 2 +- lib/bcoin/peer.js | 2 -- lib/bcoin/pool.js | 1 + lib/bcoin/spvnode.js | 4 +++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/bcoin/fullnode.js b/lib/bcoin/fullnode.js index 5c047123..3ac81cd6 100644 --- a/lib/bcoin/fullnode.js +++ b/lib/bcoin/fullnode.js @@ -131,7 +131,9 @@ function Fullnode(options) { key: this.options.sslKey, cert: this.options.sslCert, port: this.options.httpPort || this.network.rpcPort, - host: this.options.httpHost || '0.0.0.0' + host: this.options.httpHost || '0.0.0.0', + apiKey: this.options.apiKey, + auth: this.options.auth }); } diff --git a/lib/bcoin/http/client.js b/lib/bcoin/http/client.js index dac2eeab..f3196da9 100644 --- a/lib/bcoin/http/client.js +++ b/lib/bcoin/http/client.js @@ -36,7 +36,7 @@ function HTTPClient(options) { this.options = options; this.network = bcoin.network.get(options.network); - this.uri = options.uri; + this.uri = options.uri || 'localhost:' + this.network.rpcPort; this.id = null; this.socket = null; diff --git a/lib/bcoin/peer.js b/lib/bcoin/peer.js index 891c0916..f5c0854a 100644 --- a/lib/bcoin/peer.js +++ b/lib/bcoin/peer.js @@ -1824,8 +1824,6 @@ Peer.prototype.sendReject = function sendReject(code, reason, obj) { if (obj) { this.logger.debug('Rejecting %s %s (%s): ccode=%s reason=%s.', reject.message, obj.rhash, this.hostname, code, reason); - - this.pool.rejects.add(obj.hash()); } else { this.logger.debug('Rejecting packet from %s: ccode=%s reason=%s.', this.hostname, code, reason); diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index e81ccf27..7bf1b259 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -696,6 +696,7 @@ Pool.prototype._handleHeaders = function _handleHeaders(headers, peer, callback) if (!header.verify(ret)) { peer.reject(header, 'invalid', ret.reason, 100); + self.rejects.add(header.hash()); return next(new Error('Invalid header.')); } diff --git a/lib/bcoin/spvnode.js b/lib/bcoin/spvnode.js index 179797c4..5a97076e 100644 --- a/lib/bcoin/spvnode.js +++ b/lib/bcoin/spvnode.js @@ -79,7 +79,9 @@ function SPVNode(options) { key: this.options.sslKey, cert: this.options.sslCert, port: this.options.httpPort || this.network.rpcPort, - host: '0.0.0.0' + host: this.options.httpHost || '0.0.0.0', + apiKey: this.options.apiKey, + auth: this.options.auth }); }