This PR prevents consecutive ::cs_main locks in the following functions:
FlushStateToDisk()that could happen when it is called from:AcceptToMemoryPoolWithTime()CChainState::DisconnectTip()CChainState::ConnectTip()CChainState::AcceptBlock()CChainState::RewindBlockIndex()
- UnloadBlockIndex()
- CChainState::ReplayBlocks()