Make -reindex cope with out-of-order blocks

Remember out-of-order block headers along with their disk positions. This is likely the simplest and least-impact way to make -reindex work with headers first.
    
Based on top of #4468, only the last commit is mine.

Edit: Known issue:
- when restarting after -reindex it doesn't start from the right place; it should start at the position of the earliest block with unknown parent, not that of the latest valid block