package org.ethereum.manager;


import org.ethereum.core.Block;
import org.ethereum.core.Blockchain;
import org.spongycastle.util.encoders.Hex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

import static org.ethereum.config.SystemProperties.CONFIG;

@Component
public class BlockLoader {

    @Autowired
    private Blockchain blockchain;

    Scanner scanner = null;


    public void loadBlocks(){

        String fileSrc = CONFIG.blocksLoader();
        try {
            FileInputStream inputStream = null;
            inputStream = new FileInputStream(fileSrc);
            scanner = new Scanner(inputStream, "UTF-8");

            System.out.println("Loading blocks: " + fileSrc);

            while (scanner.hasNextLine()) {

                byte[] blockRLPBytes = Hex.decode( scanner.nextLine());
                Block block = new Block(blockRLPBytes);

                long t1 = System.nanoTime();
                if (block.getNumber() >= blockchain.getBestBlock().getNumber()){
                    blockchain.tryToConnect(block);
                    long t1_ = System.nanoTime();

                    float elapsed = ((float)(t1_ - t1) / 1_000_000);

                    if (block.getNumber() % 1000 == 0 || elapsed > 10_000) {
                        String result = String.format("Imported block #%d took: [%02.2f msec]",
                                block.getNumber(), elapsed);

                        System.out.println(result);
                    }
                } else{

                    if (block.getNumber() % 10000 == 0)
                        System.out.println("Skipping block #" + block.getNumber());
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.out.println(" * Done * ");
    }
}

@@ -87,21 +87,168 @@
 re.Block
-chain
+Header;%0Aimport org.ethereum.core.Blockchain;%0Aimport org.ethereum.validator.BlockHeaderValidator;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory
 ;%0Aimport
@@ -581,16 +581,162 @@
 Loader %7B
+%0A    private static final Logger logger = LoggerFactory.getLogger(%22blockqueue%22);%0A%0A    @Autowired%0A    private BlockHeaderValidator headerValidator;
 %0A%0A    @A
@@ -1428,16 +1428,152 @@
 ber())%7B%0A
+%0A                    if (block.getNumber() %3E 0 && !isValid(block.getHeader())) %7B%0A                        break;%0A                    %7D;%0A%0A
         
@@ -2321,16 +2321,16 @@
      %7D%0A%0A
-
         
@@ -2368,11 +2368,270 @@
 );%0A    %7D
+%0A%0A    private boolean isValid(BlockHeader header) %7B%0A%0A        if (!headerValidator.validate(header)) %7B%0A%0A            if (logger.isErrorEnabled())%0A                headerValidator.logErrors(logger);%0A%0A            return false;%0A        %7D%0A%0A        return true;%0A    %7D
 %0A%7D%0A

Add header validator to the BlockLoader