Reduce the scope of write lock on cs_mapBlockIndex in AcceptBlock (#1769)
Reduce the scope of write lock on cs_mapBlockIndex in AcceptBlock (#1769)

Write lock on cs_mapBlockIndex need to be taken just to mark current
block as invalid w/o waiting for MarkAllContainingChainsInvalid() to
return.

Previous to this change we could end up in a deadlock due to the
fact we end up tacking locks in this order:

WRITELOCK(cs_mapBlockIndex);
LOCK(cs_main)
READLOCK(cs_mapBlockIndex);

this could potentially lead to the same thread taking a write and read
lock at the same time. Orther than that cs_main must be taken before
cs_mapBlockIndex to avoid deadlocks among different threads.
BitcoinUnlimited/BitcoinUnlimited,Justaphf/BitcoinUnlimited,BitcoinUnlimited/BitcoinUnlimited,Justaphf/BitcoinUnlimited,Justaphf/BitcoinUnlimited,Justaphf/BitcoinUnlimited,Justaphf/BitcoinUnlimited,BitcoinUnlimited/BitcoinUnlimited,BitcoinUnlimited/BitcoinUnlimited,BitcoinUnlimited/BitcoinUnlimited,BitcoinUnlimited/BitcoinUnlimited,Justaphf/BitcoinUnlimited