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

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton committed Apr 4, 2019
1 parent 0658ffc commit bd32bb8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package tech.pegasys.pantheon.ethereum.eth.sync;

import static java.lang.Math.toIntExact;

import tech.pegasys.pantheon.ethereum.core.BlockHeader;

import java.util.Objects;
Expand Down Expand Up @@ -61,6 +63,6 @@ public String toString() {
}

public int getSegmentLength() {
return (int) (end.getNumber() - start.getNumber());
return toIntExact(end.getNumber() - start.getNumber());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private CompletableFuture<List<BlockHeader>> downloadHeaders(
protocolContext,
ethContext,
checkpointRange.getEnd(),
// -1 because we don't want to request the range starting header
checkpointRange.getSegmentLength() - 1,
validationPolicy,
metricsSystem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void runPendingFutures() {
executors.forEach(MockExecutorService::runPendingFutures);
}

public int getPendingFuturesCount() {
return executors.stream().mapToInt(MockExecutorService::getPendingFuturesCount).sum();
public long getPendingFuturesCount() {
return executors.stream().mapToLong(MockExecutorService::getPendingFuturesCount).sum();
}

public void disableAutoRun() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void runPendingFutures(final EthProtocolManager ethProtocolManager
* <p>Works with {@code disableEthSchedulerAutoRun} - tasks will only be pending if autoRun has
* been disabled.
*/
public static int getPendingFuturesCount(final EthProtocolManager ethProtocolManager) {
public static long getPendingFuturesCount(final EthProtocolManager ethProtocolManager) {
final EthScheduler scheduler = ethProtocolManager.ethContext().getScheduler();
checkArgument(
scheduler instanceof DeterministicEthScheduler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void runPendingFutures() {
currentTasks.forEach(ExecutorTask::run);
}

public int getPendingFuturesCount() {
return tasks.size();
public long getPendingFuturesCount() {
return tasks.stream().filter(ExecutorTask::isPending).count();
}

public void runPendingFuturesInSeparateThreads(final ExecutorService executorService) {
Expand Down

0 comments on commit bd32bb8

Please sign in to comment.