private void tryToBuildBetterBlock(
      final Long timestamp,
      final Bytes32 random,
      final PayloadIdentifier payloadIdentifier,
      final MergeBlockCreator mergeBlockCreator,
      final Optional<List<Withdrawal>> withdrawals,
      final Optional<Bytes32> parentBeaconBlockRoot,
      final BlockHeader parentHeader) {

    final Supplier<BlockCreationResult> blockCreator =
        () ->
            mergeBlockCreator.createBlock(
                Optional.empty(),
                random,
                timestamp,
                withdrawals,
                parentBeaconBlockRoot,
                parentHeader);

    LOG.debug(
        "Block creation started for payload id {}, remaining time is {}ms",
        payloadIdentifier,
        miningConfiguration.getUnstable().getPosBlockCreationMaxTime());

    ethScheduler
        .scheduleBlockCreationTask(
            () -> retryBlockCreationUntilUseful(payloadIdentifier, blockCreator))
        .orTimeout(
            miningConfiguration.getUnstable().getPosBlockCreationMaxTime(), TimeUnit.MILLISECONDS)
        .whenComplete(
            (unused, throwable) -> {
              if (throwable != null) {
                LOG.atDebug()
                    .setMessage("Exception building block for payload id {}, reason {}")
                    .addArgument(payloadIdentifier)
                    .addArgument(() -> logException(throwable))
                    .log();
              }
              cleanupBlockCreationTask(payloadIdentifier);
            });
  }
Instantiates a new Merge coordinator.

@param protocolContext the protocol context
@param protocolSchedule the protocol schedule
@param ethScheduler the block builder executor
@param miningParams the mining params
@param backwardSyncContext the backward sync context
@param mergeBlockCreatorFactory the merge block creator factory
consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java