private void completeTask(
      final PeerTaskResult<List<Block>> blockTaskResult,
      final Throwable throwable,
      final String blockIdentifier) {
    if (throwable != null) {
      LOG.debug(
          "Failed to download block {} from peer {} with message '{}' and cause '{}'",
          blockIdentifier,
          assignedPeer.map(EthPeer::toString).orElse("<any>"),
          throwable.getMessage(),
          throwable.getCause());
      result.completeExceptionally(throwable);
    } else if (blockTaskResult.getResult().isEmpty()) {
      blockTaskResult.getPeer().recordUselessResponse("Download block returned an empty result");
      LOG.debug(
          "Failed to download block {} from peer {} with empty result.",
          blockIdentifier,
          blockTaskResult.getPeer());
      result.completeExceptionally(new IncompleteResultsException());
    } else {
      LOG.debug(
          "Successfully downloaded block {} from peer {}.",
          blockIdentifier,
          blockTaskResult.getPeer());
      result.complete(
          new PeerTaskResult<>(blockTaskResult.getPeer(), blockTaskResult.getResult().get(0)));
    }
  }
Downloads a block from a peer. Will complete exceptionally if block cannot be downloaded.
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBlockFromPeerTask.java