net: misc.

This commit is contained in:
Christopher Jeffrey 2017-01-04 15:22:28 -08:00
parent 19c44a9779
commit eb12b0e608
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
5 changed files with 18 additions and 10 deletions

View File

@ -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}
*/

View File

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

View File

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

View File

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

View File

@ -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) {