class SyncQueueImpl implements SyncQueueIfc {

    void eraseChain(List<HeaderElement> chain, long startFrom) {
        if (chain.isEmpty())
            return;

        // prevent from going beyond dark zone
        startFrom = Math.max(darkZoneNum + 1, startFrom);

        HeaderElement head = chain.get(chain.size() - 1);
        for (int i = chain.size() - 1; i >= 0; i--) {
            HeaderElement el = chain.get(i);
            if (el.header.getNumber() < startFrom) break; // erase up to startFrom number
            Map<ByteArrayWrapper, HeaderElement> gen = headers.get(el.header.getNumber());
            gen.remove(new ByteArrayWrapper(el.header.getHash()));
            // clean empty gens
            if (gen.isEmpty()) {
                headers.remove(el.header.getNumber());
            }
        }

        // adjust maxNum
        if (head.header.getNumber() == maxNum) {
            Map<ByteArrayWrapper, HeaderElement> lastValidatedGen = headers.get(darkZoneNum);
            assert lastValidatedGen.size() == 1;
            long maxNotEmptyGen = lastValidatedGen.values().iterator().next().header.getNumber();

            // find new maxNum after chain has been erased
            for (long num = head.header.getNumber(); num >= darkZoneNum; num--) {
                Map<ByteArrayWrapper, HeaderElement> gen = headers.get(num);
                if (gen != null && !gen.isEmpty() && num > maxNotEmptyGen) {
                    maxNotEmptyGen = num;
                    break;
                }
            }
            maxNum = maxNotEmptyGen;
        }
    }

    public  SyncQueueImpl(List<Block> initBlocks);
    public  SyncQueueImpl(Blockchain bc);
    public  SyncQueueImpl(Blockchain bc, Long endBlockNumber);

}