net: misc.
This commit is contained in:
parent
19c44a9779
commit
eb12b0e608
@ -1879,8 +1879,6 @@ Chain.prototype._getLocator = co(function* getLocator(start) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the orphan root of the hash (if it is an orphan).
|
* 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
|
* @param {Hash} hash
|
||||||
* @returns {Hash}
|
* @returns {Hash}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -138,7 +138,7 @@ Packet.prototype.fromRaw = function fromRaw(data) {
|
|||||||
* @param {Number} options.ts - Timestamp of discovery.
|
* @param {Number} options.ts - Timestamp of discovery.
|
||||||
* @param {NetAddress} options.local - Our address.
|
* @param {NetAddress} options.local - Our address.
|
||||||
* @param {NetAddress} options.remote - Their address.
|
* @param {NetAddress} options.remote - Their address.
|
||||||
* @param {BN} options.nonce
|
* @param {Buffer} options.nonce
|
||||||
* @param {String} options.agent - User agent string.
|
* @param {String} options.agent - User agent string.
|
||||||
* @param {Number} options.height - Chain height.
|
* @param {Number} options.height - Chain height.
|
||||||
* @param {Boolean} options.relay - Whether transactions
|
* @param {Boolean} options.relay - Whether transactions
|
||||||
@ -148,7 +148,7 @@ Packet.prototype.fromRaw = function fromRaw(data) {
|
|||||||
* @property {Number} ts - Timestamp of discovery.
|
* @property {Number} ts - Timestamp of discovery.
|
||||||
* @property {NetAddress} local - Our address.
|
* @property {NetAddress} local - Our address.
|
||||||
* @property {NetAddress} remote - Their address.
|
* @property {NetAddress} remote - Their address.
|
||||||
* @property {BN} nonce
|
* @property {Buffer} nonce
|
||||||
* @property {String} agent - User agent string.
|
* @property {String} agent - User agent string.
|
||||||
* @property {Number} height - Chain height.
|
* @property {Number} height - Chain height.
|
||||||
* @property {Boolean} relay - Whether transactions
|
* @property {Boolean} relay - Whether transactions
|
||||||
|
|||||||
@ -1893,8 +1893,9 @@ Peer.prototype.handleGetData = co(function* handleGetData(packet) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case invTypes.CMPCT_BLOCK:
|
case invTypes.CMPCT_BLOCK:
|
||||||
// Fallback to full block.
|
|
||||||
height = yield this.chain.db.getHeight(item.hash);
|
height = yield this.chain.db.getHeight(item.hash);
|
||||||
|
|
||||||
|
// Fallback to full block.
|
||||||
if (height < this.chain.tip.height - 10) {
|
if (height < this.chain.tip.height - 10) {
|
||||||
result = yield this.sendBlock(item, this.compactWitness);
|
result = yield this.sendBlock(item, this.compactWitness);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@ -1912,7 +1913,7 @@ Peer.prototype.handleGetData = co(function* handleGetData(packet) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield this.sendCompactBlock(block, this.compactWitness);
|
this.sendCompactBlock(block, this.compactWitness);
|
||||||
|
|
||||||
blocks++;
|
blocks++;
|
||||||
|
|
||||||
|
|||||||
@ -657,6 +657,14 @@ Pool.prototype.addLoader = function addLoader() {
|
|||||||
return;
|
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);
|
addr = this.getHost(false);
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
@ -1083,8 +1091,6 @@ Pool.prototype.handleBlock = co(function* handleBlock(block, peer) {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer.reject(block, err.code, err.reason, err.score);
|
|
||||||
|
|
||||||
if (err.reason === 'bad-prevblk') {
|
if (err.reason === 'bad-prevblk') {
|
||||||
if (this.options.headers) {
|
if (this.options.headers) {
|
||||||
peer.increaseBan(10);
|
peer.increaseBan(10);
|
||||||
@ -1096,7 +1102,10 @@ Pool.prototype.handleBlock = co(function* handleBlock(block, peer) {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peer.reject(block, err.code, err.reason, err.score);
|
||||||
|
|
||||||
this.scheduleRequests(peer);
|
this.scheduleRequests(peer);
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -184,8 +184,8 @@ Bloom.prototype.getSize = function getSize() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize bloom filter.
|
* Write filter to buffer writer.
|
||||||
* @returns {Buffer}
|
* @param {BufferWriter} bw
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Bloom.prototype.toWriter = function toWriter(bw) {
|
Bloom.prototype.toWriter = function toWriter(bw) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user