blockchain: Make version 5 update atomic.
blockchain: Make version 5 update atomic.

This modifies the version 5 migration code to update the database
version atomically with setting a reindex tip and resetting the best
chain tip back to the genesis block so the chain can be reindexed.

This is necessary because, unlike the modifications that come before it,
storing the current chain tip and resetting it is not idempotent, so
lack of atomicity in those updates can lead to failure to recover in
unclean shutdown circumstances.

decred/dcrd,decred/dcrd,jrick/dcrd,jrick/dcrd