comments. misc.
This commit is contained in:
parent
e04aed96d0
commit
9976208d0d
@ -263,10 +263,11 @@ Pool.prototype._addLoader = function _addLoader() {
|
|||||||
|
|
||||||
if (!self.options.fullNode) {
|
if (!self.options.fullNode) {
|
||||||
// Request each block
|
// Request each block
|
||||||
hashes.forEach(function(hash) {
|
for (i = 0; i < hashes.length; i++) {
|
||||||
self._request('filtered', hash);
|
self._request('filtered', hashes[i]);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// Push our getblocks packet
|
||||||
self._scheduleRequests();
|
self._scheduleRequests();
|
||||||
|
|
||||||
// The part of the response is in chain, no need to escalate requests
|
// The part of the response is in chain, no need to escalate requests
|
||||||
@ -295,25 +296,42 @@ Pool.prototype._addLoader = function _addLoader() {
|
|||||||
|
|
||||||
for (i = 0; i < hashes.length; i++) {
|
for (i = 0; i < hashes.length; i++) {
|
||||||
hash = hashes[i];
|
hash = hashes[i];
|
||||||
|
|
||||||
|
// Resolve orphan chain
|
||||||
if (self.chain.hasOrphan(hash)) {
|
if (self.chain.hasOrphan(hash)) {
|
||||||
peer.loadBlocks(self.chain.locatorHashes(), self.chain.getOrphanRoot(hash));
|
peer.loadBlocks(
|
||||||
|
self.chain.locatorHashes(),
|
||||||
|
self.chain.getOrphanRoot(hash)
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restart the entire getblocks process
|
||||||
if (i === hashes.length - 1)
|
if (i === hashes.length - 1)
|
||||||
peer.loadBlocks(self.chain.locatorHashes(), 0);
|
peer.loadBlocks(self.chain.locatorHashes(), 0);
|
||||||
|
|
||||||
|
// Request block if we don't have it
|
||||||
if (!self.chain.hasBlock(hash))
|
if (!self.chain.hasBlock(hash))
|
||||||
self._request('block', hash);
|
self._request('block', hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.emit('debug',
|
||||||
|
'Requesting %s block packets from %s with getdata',
|
||||||
|
self.request.active,
|
||||||
|
peer.address
|
||||||
|
);
|
||||||
|
|
||||||
|
// Push our getblocks packet
|
||||||
self._scheduleRequests();
|
self._scheduleRequests();
|
||||||
|
|
||||||
|
// Store last hash because we can
|
||||||
self.block.lastHash = hashes[hashes.length - 1];
|
self.block.lastHash = hashes[hashes.length - 1];
|
||||||
|
|
||||||
|
// Reset interval to avoid calling getblocks unnecessarily
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
interval = setInterval(load, self.load.interval);
|
interval = setInterval(load, self.load.interval);
|
||||||
|
|
||||||
|
// Reset timeout to avoid killing the loader
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
timer = setTimeout(destroy, self.load.timeout);
|
timer = setTimeout(destroy, self.load.timeout);
|
||||||
});
|
});
|
||||||
@ -417,7 +435,7 @@ Pool.prototype._load = function _load() {
|
|||||||
|
|
||||||
this.load.hiReached = false;
|
this.load.hiReached = false;
|
||||||
|
|
||||||
console.log(
|
this.emit('debug',
|
||||||
'Requesting inv packet from %s with getblocks',
|
'Requesting inv packet from %s with getblocks',
|
||||||
this.peers.load.address);
|
this.peers.load.address);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user