Skip to content

Commit

Permalink
edge cases fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed May 29, 2024
1 parent a78130c commit c8054b0
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ private SafeFuture<Boolean> processNextBlock(final RequestState requestState) {
// Ensure blocks are loaded off of the event thread
return requestState
.loadNextBlock()
.thenCompose(block -> handleLoadedBlock(requestState, block));
.thenCompose(
block -> {
requestState.decrementRemainingBlocks();
return handleLoadedBlock(requestState, block);
});
}

/** Sends the block and returns true if the request is now complete. */
Expand Down Expand Up @@ -287,13 +291,11 @@ SafeFuture<Void> sendBlock(final SignedBeaconBlock block) {
if (step.isGreaterThan(1L)) {
remainingBlocks = ZERO;
}
return callback
.respond(block)
.thenRun(
() -> {
sentBlocks.incrementAndGet();
remainingBlocks = remainingBlocks.minusMinZero(1);
});
return callback.respond(block).thenRun(sentBlocks::incrementAndGet);
}

void decrementRemainingBlocks() {
remainingBlocks = remainingBlocks.minusMinZero(1);
}

void incrementCurrentSlot() {
Expand Down

0 comments on commit c8054b0

Please sign in to comment.