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.
|
||||
* @param {Headers[]} items
|
||||
|
||||
@ -1356,7 +1356,7 @@ Pool.prototype.handleGetData = co(function* handleGetData(peer, packet) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1435,10 +1435,8 @@ Pool.prototype.handleGetBlocks = co(function* handleGetBlocks(peer, packet) {
|
||||
while (hash) {
|
||||
blocks.push(new InvItem(invTypes.BLOCK, hash));
|
||||
|
||||
if (hash === packet.stop) {
|
||||
peer.hashContinue = hash;
|
||||
if (hash === packet.stop)
|
||||
break;
|
||||
}
|
||||
|
||||
if (blocks.length === 500) {
|
||||
peer.hashContinue = hash;
|
||||
@ -1490,10 +1488,10 @@ Pool.prototype.handleGetHeaders = co(function* handleGetHeaders(peer, packet) {
|
||||
while (entry) {
|
||||
headers.push(entry.toHeaders());
|
||||
|
||||
if (headers.length === 2000)
|
||||
if (entry.hash === packet.stop)
|
||||
break;
|
||||
|
||||
if (entry.hash === packet.stop)
|
||||
if (headers.length === 2000)
|
||||
break;
|
||||
|
||||
entry = yield entry.getNext();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user