Fix csBestBlock/cvBlockChange waiting in rpc/mining #12743

pull sipa wants to merge 2 commits into bitcoin:master from sipa:201803_waitblockchange changing 4 files +15 −9
  1. sipa commented at 4:06 AM on March 21, 2018: member

    This is an alternative to #11694.

    It reintroduces a uint256 variable with the best block hash, protected by csBestBlock, and only updated while holding it.

    Also rename the involved variable to modern guidelines, as there are very few uses.

  2. sipa cross-referenced this on Mar 21, 2018 from issue rpc: Add missing cs_main lock in getblocktemplate(...) by practicalswift
  3. fanquake added the label RPC/REST/ZMQ on Mar 21, 2018
  4. practicalswift commented at 7:08 AM on March 21, 2018: contributor

    Concept ACK! Much better than PR #11694 which I'm now closing :-)

  5. promag commented at 3:24 PM on March 21, 2018: member

    utACK 42be289.

  6. in src/validation.h:168 in 42be289df0 outdated
     162 | @@ -163,8 +163,9 @@ extern BlockMap& mapBlockIndex;
     163 |  extern uint64_t nLastBlockTx;
     164 |  extern uint64_t nLastBlockWeight;
     165 |  extern const std::string strMessageMagic;
     166 | -extern CWaitableCriticalSection csBestBlock;
     167 | -extern CConditionVariable cvBlockChange;
     168 | +extern CWaitableCriticalSection cs_best_block;
     169 | +extern CConditionVariable cv_best_block_change;
     170 | +extern uint256 best_block_hash;
    


    ryanofsky commented at 7:24 PM on April 3, 2018:

    Maybe prefix global variable name with g_. (I would probably call these g_best_block g_best_block_mutex g_best_block_cv.)


    sipa commented at 1:02 AM on April 4, 2018:

    Fixed.

  7. ryanofsky commented at 7:26 PM on April 3, 2018: contributor

    utACK 42be289df0c277777f7bbfc383ca7520140775cf. Nice simple bugfix.

  8. sipa force-pushed on Apr 4, 2018
  9. promag commented at 1:15 AM on April 4, 2018: member

    utACK d1cbc67a.

  10. luke-jr commented at 1:32 AM on April 4, 2018: member

    utACK, although would prefer the renaming was in a separate commit.

  11. Fix csBestBlock/cvBlockChange waiting in rpc/mining 45dd135039
  12. Modernize best block mutex/cv/hash variable naming 4a6c0e3dcf
  13. sipa force-pushed on Apr 4, 2018
  14. sipa commented at 4:54 AM on April 4, 2018: member

    @luke-jr Done.

  15. ryanofsky commented at 6:41 PM on April 4, 2018: contributor

    utACK 4a6c0e3dcfdca98270cb96b73db4c3d4446dba50. Only change since last review renaming variables and splitting commit.

  16. jnewbery commented at 8:42 PM on April 4, 2018: member

    utACK 4a6c0e3dcfdca98270cb96b73db4c3d4446dba50

    Travis timeout. Kicking.

  17. sipa merged this on Apr 13, 2018
  18. sipa closed this on Apr 13, 2018

  19. sipa referenced this in commit 4ba6da5574 on Apr 13, 2018
  20. ryanofsky cross-referenced this on Apr 13, 2018 from issue Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection by ryanofsky
  21. MarcoFalke referenced this in commit ea5f16903d on Apr 20, 2018
  22. MarcoFalke referenced this in commit a25ef49dbf on May 24, 2018
  23. MarcoFalke referenced this in commit 69fbb83b63 on May 24, 2018
  24. MarcoFalke referenced this in commit a0d004a0a4 on May 29, 2018
  25. luke-jr cross-referenced this on Jul 13, 2018 from issue 0.16: Remaining backports for 0.16.2 by MarcoFalke
  26. MarcoFalke referenced this in commit 657dfc5bca on Jul 13, 2018
  27. HashUnlimited referenced this in commit 0e4951f21a on Jan 11, 2019
  28. PastaPastaPasta referenced this in commit 1cfba98147 on Apr 12, 2020
  29. PastaPastaPasta referenced this in commit beb57b1333 on Apr 16, 2020
  30. PastaPastaPasta referenced this in commit e480ae9fa8 on Apr 16, 2020
  31. ckti referenced this in commit d5ee70493f on Mar 28, 2021
  32. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:54 UTC