Skip to content

Make SetBestChain() atomic#2058

Merged
sipa merged 1 commit intobitcoin:masterfrom
sipa:atomicreorg
Dec 3, 2012
Merged

Make SetBestChain() atomic#2058
sipa merged 1 commit intobitcoin:masterfrom
sipa:atomicreorg

Conversation

@sipa
Copy link
Member

@sipa sipa commented Dec 1, 2012

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.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/57b7b8137e23d877bd4d6d8f750ed1a87b65681d for binaries and test log.

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/11c2cb7a7f8ed2234ccbb7a1eb25135afc518eed for binaries and test log.

@gavinandresen
Copy link
Contributor

ACK

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.
@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/d33a9218abda80d32239789f6ceaec6d68a290ce for binaries and test log.

sipa added a commit that referenced this pull request Dec 3, 2012
Make SetBestChain() atomic
@sipa sipa merged commit 469e606 into bitcoin:master Dec 3, 2012
@sipa sipa deleted the atomicreorg branch May 3, 2013 18:53
laudney pushed a commit to reddcoin-project/reddcoin-3.10 that referenced this pull request Mar 19, 2014
HashUnlimited pushed a commit to chaincoin/chaincoin that referenced this pull request Jun 4, 2018
* move nStart closer to used and initialize it

* Quells warning displayed with `-Wmaybe-uninitialized` flag

* remove unused mnEntries vectors

* add devnet magic bytes to mininode.py

* remove unused governance-misc.h file

* remove old TODO comments

* replace map count/insert w/emplace in instantx.cpp

This feels like an optimization, something about:

```
if map.count(key)
     return false
else
     insert(pair)
     return true
```

... just feels icky. Plus, `vote.GetMasternodeOutpoint()` is only called
once. The previous version might be slightly more readable, however.

* Revert "replace map count/insert w/emplace in instantx.cpp"

This reverts commit d7f876e.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants