diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 2ba59090..1b99e757 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -1879,8 +1879,6 @@ Chain.prototype._getLocator = co(function* getLocator(start) { /** * Calculate the orphan root of the hash (if it is an orphan). - * Will also calculate "orphan soil" -- the block needed - * in * order to resolve the orphan root. * @param {Hash} hash * @returns {Hash} */ diff --git a/lib/net/packets.js b/lib/net/packets.js index 1fbabf4f..34f3f571 100644 --- a/lib/net/packets.js +++ b/lib/net/packets.js @@ -138,7 +138,7 @@ Packet.prototype.fromRaw = function fromRaw(data) { * @param {Number} options.ts - Timestamp of discovery. * @param {NetAddress} options.local - Our address. * @param {NetAddress} options.remote - Their address. - * @param {BN} options.nonce + * @param {Buffer} options.nonce * @param {String} options.agent - User agent string. * @param {Number} options.height - Chain height. * @param {Boolean} options.relay - Whether transactions @@ -148,7 +148,7 @@ Packet.prototype.fromRaw = function fromRaw(data) { * @property {Number} ts - Timestamp of discovery. * @property {NetAddress} local - Our address. * @property {NetAddress} remote - Their address. - * @property {BN} nonce + * @property {Buffer} nonce * @property {String} agent - User agent string. * @property {Number} height - Chain height. * @property {Boolean} relay - Whether transactions diff --git a/lib/net/peer.js b/lib/net/peer.js index d670f636..1091c860 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -1893,8 +1893,9 @@ Peer.prototype.handleGetData = co(function* handleGetData(packet) { break; case invTypes.CMPCT_BLOCK: - // Fallback to full block. height = yield this.chain.db.getHeight(item.hash); + + // Fallback to full block. if (height < this.chain.tip.height - 10) { result = yield this.sendBlock(item, this.compactWitness); if (!result) { @@ -1912,7 +1913,7 @@ Peer.prototype.handleGetData = co(function* handleGetData(packet) { continue; } - yield this.sendCompactBlock(block, this.compactWitness); + this.sendCompactBlock(block, this.compactWitness); blocks++; diff --git a/lib/net/pool.js b/lib/net/pool.js index 0a8f4e1e..5cca6045 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -657,6 +657,14 @@ Pool.prototype.addLoader = function addLoader() { return; } + for (peer = this.peers.head(); peer; peer = peer.next) { + if (!peer.outbound) + continue; + this.logger.info('Repurposing peer for loader (%s).', peer.hostname); + this.setLoader(peer); + return; + } + addr = this.getHost(false); if (!addr) @@ -1083,8 +1091,6 @@ Pool.prototype.handleBlock = co(function* handleBlock(block, peer) { throw err; } - peer.reject(block, err.code, err.reason, err.score); - if (err.reason === 'bad-prevblk') { if (this.options.headers) { peer.increaseBan(10); @@ -1096,7 +1102,10 @@ Pool.prototype.handleBlock = co(function* handleBlock(block, peer) { throw err; } + peer.reject(block, err.code, err.reason, err.score); + this.scheduleRequests(peer); + throw err; } diff --git a/lib/utils/bloom.js b/lib/utils/bloom.js index 06c74100..29502aa6 100644 --- a/lib/utils/bloom.js +++ b/lib/utils/bloom.js @@ -184,8 +184,8 @@ Bloom.prototype.getSize = function getSize() { }; /** - * Serialize bloom filter. - * @returns {Buffer} + * Write filter to buffer writer. + * @param {BufferWriter} bw */ Bloom.prototype.toWriter = function toWriter(bw) {