Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
NC-1815 Rinkeby import can stall with too many fragments
Browse files Browse the repository at this point in the history
Move "complete what we just got" semantic into the
DownloadHeaderSequenceTask.  Previously it was completing everything
in the chunk it was assigned.
  • Loading branch information
shemnon committed Nov 12, 2018
1 parent 8d8d4e4 commit f101148
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected CompletableFuture<List<BlockHeader>> executePeerTask() {
return task.whenComplete(
(r, t) -> {
// We're done if we've filled all requested headers
if (r != null && r.size() == segmentLength) {
if (lastFilledHeaderIndex == 0) {
LOG.debug(
"Finished downloading headers from {} to {}.",
startingBlockNumber,
Expand Down Expand Up @@ -162,6 +162,7 @@ private CompletableFuture<List<BlockHeader>> processHeaders(
final CompletableFuture<List<BlockHeader>> future = new CompletableFuture<>();
BlockHeader child = null;
boolean firstSkipped = false;
final int previousHeaderIndex = lastFilledHeaderIndex;
for (final BlockHeader header : headersResult.getResult()) {
final int headerIndex =
Ints.checkedCast(
Expand Down Expand Up @@ -191,7 +192,7 @@ private CompletableFuture<List<BlockHeader>> processHeaders(
lastFilledHeaderIndex = headerIndex;
child = header;
}
future.complete(asList(headers).subList(lastFilledHeaderIndex, segmentLength));
future.complete(asList(headers).subList(lastFilledHeaderIndex, previousHeaderIndex));
return future;
});
}
Expand Down

0 comments on commit f101148

Please sign in to comment.