bitcoin/bitcoin — pull request #2058 by sipa (2012-12-01 16:41:21+00:00)
Title: Make SetBestChain() atomic

In case a reorganisation fails, the internal state could become inconsistent (memory only). Previously, a cache per block connect or disconnect action was used, so blocks could not be applied in a partial way. Extend this to a cache for the entire reorganisation, making it atomic entirely. This also simplifies the code a bit.

I haven't seen any reports of problems because of this, but it should be fixed.