pool: add forceInv for getdata.
This commit is contained in:
parent
d035eb10eb
commit
cdcdb7bd52
@ -787,6 +787,18 @@ Peer.prototype.flushInv = function flushInv() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force send an inv (no filter check).
|
||||||
|
* @param {InvItem[]} items
|
||||||
|
*/
|
||||||
|
|
||||||
|
Peer.prototype.forceInv = function forceInv(items) {
|
||||||
|
if (!Array.isArray(items))
|
||||||
|
items = [items];
|
||||||
|
|
||||||
|
this.send(new packets.InvPacket(items));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send headers to a peer.
|
* Send headers to a peer.
|
||||||
* @param {Headers[]} items
|
* @param {Headers[]} items
|
||||||
|
|||||||
@ -1356,7 +1356,7 @@ Pool.prototype.handleGetData = co(function* handleGetData(peer, packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item.hash === peer.hashContinue) {
|
if (item.hash === peer.hashContinue) {
|
||||||
peer.sendInv([new InvItem(invTypes.BLOCK, this.chain.tip.hash)]);
|
peer.forceInv([new InvItem(invTypes.BLOCK, this.chain.tip.hash)]);
|
||||||
peer.hashContinue = null;
|
peer.hashContinue = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1435,10 +1435,8 @@ Pool.prototype.handleGetBlocks = co(function* handleGetBlocks(peer, packet) {
|
|||||||
while (hash) {
|
while (hash) {
|
||||||
blocks.push(new InvItem(invTypes.BLOCK, hash));
|
blocks.push(new InvItem(invTypes.BLOCK, hash));
|
||||||
|
|
||||||
if (hash === packet.stop) {
|
if (hash === packet.stop)
|
||||||
peer.hashContinue = hash;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (blocks.length === 500) {
|
if (blocks.length === 500) {
|
||||||
peer.hashContinue = hash;
|
peer.hashContinue = hash;
|
||||||
@ -1490,10 +1488,10 @@ Pool.prototype.handleGetHeaders = co(function* handleGetHeaders(peer, packet) {
|
|||||||
while (entry) {
|
while (entry) {
|
||||||
headers.push(entry.toHeaders());
|
headers.push(entry.toHeaders());
|
||||||
|
|
||||||
if (headers.length === 2000)
|
if (entry.hash === packet.stop)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (entry.hash === packet.stop)
|
if (headers.length === 2000)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
entry = yield entry.getNext();
|
entry = yield entry.getNext();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user