class PersistBlockTask extends AbstractEthTask<Block> {

  public static Supplier<CompletableFuture<List<Block>>> forSequentialBlocks(
      final ProtocolSchedule protocolSchedule,
      final ProtocolContext protocolContext,
      final EthContext ethContext,
      final List<Block> blocks,
      final HeaderValidationMode headerValidationMode,
      final MetricsSystem metricsSystem) {
    checkArgument(!blocks.isEmpty(), "No blocks to import provided");
    return () -> {
      final List<Block> successfulImports = new ArrayList<>();
      final Iterator<Block> blockIterator = blocks.iterator();
      CompletableFuture<Block> future =
          importBlockAndAddToList(
              protocolSchedule,
              protocolContext,
              ethContext,
              blockIterator.next(),
              successfulImports,
              headerValidationMode,
              metricsSystem);
      while (blockIterator.hasNext()) {
        final Block block = blockIterator.next();
        future =
            future.thenCompose(
                b ->
                    importBlockAndAddToList(
                        protocolSchedule,
                        protocolContext,
                        ethContext,
                        block,
                        successfulImports,
                        headerValidationMode,
                        metricsSystem));
      }
      return future.thenApply(r -> successfulImports);
    };
  }

  private  PersistBlockTask(
      final ProtocolSchedule protocolSchedule,
      final ProtocolContext protocolContext,
      final EthContext ethContext,
      final Block block,
      final HeaderValidationMode headerValidationMode,
      final MetricsSystem metricsSystem);

}