class ConsensusValidationMainchainViewImpl implements ConsensusValidationMainchainView {

    @Override
    public synchronized List<BlockHeader> get(Keccak256 startingHashToGetMainchainFrom, int height) {
        List<BlockHeader> headers = new ArrayList<>();

        Keccak256 currentHash = startingHashToGetMainchainFrom;
        for(int i = 0; i < height; i++) {
            Block block = blockStore.getBlockByHash(currentHash.getBytes());
            BlockHeader header;
            if (block != null) {
                header = block.getHeader();
            } else {
                if(pendingHeadersByHash == null) {
                    logger.error("Pending headers by hash has not been set.");
                    return new ArrayList<>();
                }
                header = pendingHeadersByHash.get(currentHash);
            }

            if(header == null) {
                return new ArrayList<>();
            }

            headers.add(header);
            currentHash = header.getParentHash();
        }

        return headers;
    }

    public  ConsensusValidationMainchainViewImpl(BlockStore blockStore);

}