[Qt] rework setNumBlocks to have blockDate as parameter #5776

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:qt_lock changing 7 files +28 −23
  1. Diapolo commented at 10:52 AM on February 9, 2015: none
    • reduces some functional overhead and simplifies the code
  2. gmaxwell added the label GUI on Feb 10, 2015
  3. Diapolo commented at 7:47 PM on February 14, 2015: none

    @laanwj Before I continue with this here, is this a thing you consider valuable?

    Ping² :-D

  4. in src/qt/clientmodel.cpp:None in 960cdc1a66 outdated
      59 | @@ -60,9 +60,11 @@ int ClientModel::getNumConnections(unsigned int flags) const
      60 |      return nNum;
      61 |  }
      62 |  
      63 | -int ClientModel::getNumBlocks() const
      64 | +int ClientModel::getNumBlocks(bool fLock) const
      65 |  {
      66 | -    LOCK(cs_main);
      67 | +    if (fLock)
      68 | +        LOCK(cs_main);
    


    laanwj commented at 8:40 AM on March 9, 2015:

    This cannot work. LOCK locks within the current scope, which is empty here.


    laanwj commented at 8:43 AM on March 9, 2015:

    Instead of a boolean argument (boolean arguments tend to make code unreadable), it is better done by having two functions:

    int getNumBlocksWithLock() const
    {
        LOCK(cs_main);
        return getNumBlocks();
    }
    int getNumBlocks() const
    {
        return chainActive.Height();
    }
    

    But as we use recursive locks everywhere there should be no reason to. If you have the lock, taking it again i harmless.

  5. laanwj commented at 8:47 AM on March 9, 2015: member

    Concept ACK. It is better to have necessary information be part of the message. Please remove the locking changes, they are incorrect and unnecessary.

  6. [Qt] rework setNumBlocks to have blockDate as parameter
    - reduces some functional overhead and simplifies the code
    8517e9709e
  7. Diapolo commented at 9:58 AM on March 9, 2015: none

    @laanwj Removed the locking changes, thanks for the review.

  8. laanwj merged this on Mar 9, 2015
  9. laanwj closed this on Mar 9, 2015

  10. laanwj referenced this in commit f50120ab4d on Mar 9, 2015
  11. Diapolo deleted the branch on Mar 9, 2015
  12. MarcoFalke locked this on Sep 8, 2021
Contributors
Labels

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-04-21 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me