@Override
  public void onBlockAdded(final BlockAddedEvent event) {
    final long currentBlock = event.getBlock().getHeader().getNumber();
    final MiningCoordinator nextMiningCoordinator =
        miningCoordinatorSchedule.getFork(currentBlock + 1).getValue();

    if (activeMiningCoordinator != nextMiningCoordinator) {
      LOG.trace(
          "Migrating mining coordinator at block {} from {} to {}",
          currentBlock,
          activeMiningCoordinator.getClass().getSimpleName(),
          nextMiningCoordinator.getClass().getSimpleName());

      final Runnable stopActiveCoordinatorTask = () -> activeMiningCoordinator.stop();
      final Runnable startNextCoordinatorTask =
          () -> {
            activeMiningCoordinator = nextMiningCoordinator;
            startActiveMiningCoordinator();
            if (activeMiningCoordinator instanceof BlockAddedObserver) {
              ((BlockAddedObserver) activeMiningCoordinator).onBlockAdded(event);
            }
          };

      CompletableFuture.runAsync(stopActiveCoordinatorTask).thenRun(startNextCoordinatorTask);

    } else if (activeMiningCoordinator instanceof BlockAddedObserver) {
      ((BlockAddedObserver) activeMiningCoordinator).onBlockAdded(event);
    }
  }
Instantiates a new Migrating mining coordinator.

@param miningCoordinatorSchedule the mining coordinator schedule
@param blockchain the blockchain
consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingMiningCoordinator.java