Headers-based synchronization and parallel block download

(see individual commits, in particular "Switch to headers-based synchronization", for detailed explanation of the changes).

This implements headers-based synchronization and parallel block download. Summary of the changes:
* Use `getheaders` instead of `getblocks` based synchronization, so that the best block in the chain is always known before actually downloading it. No more orphan blocks, ever.
* Use a moving-window based block downloading mechanism (the heuristics are simple and behave badly for very small blocks, but except for the very beginning of the chain, it works very well).
* Allow blocks to be stored out-of-order in the block database files.
* Reorganize the block connection logic significantly.
* Add a `getblockheader` RPC command.