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).
|
||||
* Will also calculate "orphan soil" -- the block needed
|
||||
* in * order to resolve the orphan root.
|
||||
* @param {Hash} hash
|
||||
* @returns {Hash}
|
||||
*/
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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++;
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user