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

NC-1880 High TX volume swamps block processing #337

Merged
merged 5 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
* method name changes
  • Loading branch information
shemnon committed Dec 1, 2018
commit e3d62b0205474fe13a6b87c3997fe217d09322ef
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected final <S> CompletableFuture<S> executeSubTask(
*/
protected final <S> CompletableFuture<S> executeWorkerSubTask(
final EthScheduler scheduler, final Supplier<CompletableFuture<S>> subTask) {
return executeSubTask(() -> scheduler.scheduleWorkerTask(subTask));
return executeSubTask(() -> scheduler.scheduleSyncWorkerTask(subTask));
}

public final T result() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ protected EthScheduler(
this.txWorkerExecutor = txWorkerExecutor;
}

public <T> CompletableFuture<T> scheduleWorkerTask(final Supplier<CompletableFuture<T>> future) {
public <T> CompletableFuture<T> scheduleSyncWorkerTask(
final Supplier<CompletableFuture<T>> future) {
final CompletableFuture<T> promise = new CompletableFuture<>();
final Future<?> workerFuture =
syncWorkerExecutor.submit(
Expand All @@ -100,11 +101,11 @@ public <T> CompletableFuture<T> scheduleWorkerTask(final Supplier<CompletableFut
return promise;
}

public Future<?> scheduleWorkerTask(final Runnable command) {
public Future<?> scheduleSyncWorkerTask(final Runnable command) {
return syncWorkerExecutor.submit(command);
}

public Future<?> scheduleTransactionTask(final Runnable command) {
public Future<?> scheduleTxWorkerTask(final Runnable command) {
return txWorkerExecutor.submit(command);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void onBlockAdded(final BlockAddedEvent blockAddedEvent, final Blockchai
protocolSchedule, protocolContext, readyForImport, HeaderValidationMode.FULL);
ethContext
.getScheduler()
.scheduleWorkerTask(importBlocksTask)
.scheduleSyncWorkerTask(importBlocksTask)
.whenComplete(
(r, t) -> {
if (r != null) {
Expand Down Expand Up @@ -243,7 +243,7 @@ CompletableFuture<Block> importOrSavePendingBlock(final Block block) {
protocolSchedule, protocolContext, block, HeaderValidationMode.FULL);
return ethContext
.getScheduler()
.scheduleWorkerTask(importTask::run)
.scheduleSyncWorkerTask(importTask::run)
.whenComplete(
(r, t) -> {
if (t != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public void onTransactionsAdded(final Iterable<Transaction> transactions) {
transaction -> transactionTracker.addToPeerSendQueue(peer, transaction)));
ethContext
.getScheduler()
.scheduleWorkerTask(transactionsMessageSender::sendTransactionsToPeers);
.scheduleSyncWorkerTask(transactionsMessageSender::sendTransactionsToPeers);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public TransactionsMessageHandler(
@Override
public void exec(final EthMessage message) {
final TransactionsMessage transactionsMessage = TransactionsMessage.readFrom(message.getData());
scheduler.scheduleTransactionTask(
scheduler.scheduleTxWorkerTask(
() ->
transactionsMessageProcessor.processTransactionsMessage(
message.getPeer(), transactionsMessage));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void setup() {
@Test
public void scheduleWorkerTask_completesWhenScheduledTaskCompletes() {
final CompletableFuture<Object> future = new CompletableFuture<>();
final CompletableFuture<Object> result = ethScheduler.scheduleWorkerTask(() -> future);
final CompletableFuture<Object> result = ethScheduler.scheduleSyncWorkerTask(() -> future);

assertThat(result.isDone()).isFalse();
future.complete("bla");
Expand All @@ -58,7 +58,7 @@ public void scheduleWorkerTask_completesWhenScheduledTaskCompletes() {
@Test
public void scheduleWorkerTask_completesWhenScheduledTaskFails() {
final CompletableFuture<Object> future = new CompletableFuture<>();
final CompletableFuture<Object> result = ethScheduler.scheduleWorkerTask(() -> future);
final CompletableFuture<Object> result = ethScheduler.scheduleSyncWorkerTask(() -> future);

assertThat(result.isDone()).isFalse();
future.completeExceptionally(new RuntimeException("whoops"));
Expand All @@ -70,7 +70,7 @@ public void scheduleWorkerTask_completesWhenScheduledTaskFails() {
@Test
public void scheduleWorkerTask_completesWhenScheduledTaskIsCancelled() {
final CompletableFuture<Object> future = new CompletableFuture<>();
final CompletableFuture<Object> result = ethScheduler.scheduleWorkerTask(() -> future);
final CompletableFuture<Object> result = ethScheduler.scheduleSyncWorkerTask(() -> future);

assertThat(result.isDone()).isFalse();
future.cancel(false);
Expand All @@ -82,7 +82,7 @@ public void scheduleWorkerTask_completesWhenScheduledTaskIsCancelled() {
@Test
public void scheduleWorkerTask_cancelsScheduledFutureWhenResultIsCancelled() {
final CompletableFuture<Object> result =
ethScheduler.scheduleWorkerTask(() -> new CompletableFuture<>());
ethScheduler.scheduleSyncWorkerTask(() -> new CompletableFuture<>());

assertThat(syncWorkerExecutor.getScheduledFutures().size()).isEqualTo(1);
final Future<?> future = syncWorkerExecutor.getScheduledFutures().get(0);
Expand Down