refactor: Move GetDifficulty out of `rpc/server.h` #10095

pull laanwj wants to merge 3 commits into bitcoin:master from laanwj:2017_03_getdifficulty_header changing 8 files +52 −17
  1. laanwj commented at 12:31 PM on March 27, 2017: member

    GetDifficulty has no business in rpcserver.h. Define it in the interface header of the implementation unit rpcblockchain where it is defined.

    Also modernize the signature to:

    double GetDifficulty(const CBlockIndex* blockindex = nullptr);

    (remove extern, replace NULL with nullptr)

  2. refactor: Move GetDifficulty out of `rpc/server.h`
    It has no business in `rpcserver.h`. Define it in the interface header
    of the implementation unit `rpcblockchain` where it is defined.
    
    Also modernize the signature to:
    
        double GetDifficulty(const CBlockIndex* blockindex = nullptr);
    
    (remove `extern`, replace `NULL` with `nullptr`)
    e6dcfeec05
  3. laanwj added the label Refactoring on Mar 27, 2017
  4. laanwj cross-referenced this on Mar 27, 2017 from issue RPC: cleanups in rpc/server by jtimon
  5. jonasschnelli commented at 1:27 PM on March 27, 2017: contributor

    utACK e6dcfeec05d6527ab148550836937ff435e6449c

  6. laanwj commented at 2:05 PM on March 27, 2017: member

    @jnewbery Done

  7. laanwj commented at 2:07 PM on March 27, 2017: member

    I see rest.cpp also uses a few functions from this file:

    extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
    extern UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
    extern UniValue mempoolInfoToJSON();
    extern UniValue mempoolToJSON(bool fVerbose = false);
    extern void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
    extern UniValue blockheaderToJSON(const CBlockIndex* blockindex);
    

    Going to add them to the header as well.

  8. refactor: Move RPCNotifyBlockChange out of `rpc/server.h` 8d8f28dd52
  9. laanwj force-pushed on Mar 27, 2017
  10. jnewbery commented at 3:07 PM on March 27, 2017: member

    Looks good to me. Tested ACK c7e9aa7c1a92adba141958e5f86d267f34cc9508

  11. dcousens approved
  12. jtimon commented at 4:29 PM on March 28, 2017: contributor

    ScriptPubKeyToJSON and TxToJSON are defined in https://github.com/bitcoin/bitcoin/blob/master/src/rpc/rawtransaction.cpp#L37 not rpc/blockchain.cpp. Either move the declaration or the definition for both to be in the same .h and .cpp

    utACK c7e9aa7c1a92adba141958e5f86d267f34cc9508 modulo nit.

  13. laanwj commented at 5:11 PM on March 28, 2017: member

    @jtimon Good catch. I'll move them to their own header.

  14. jnewbery commented at 5:32 PM on March 28, 2017: member

    Or just refactor them out entirely since they're duplicate code: https://github.com/bitcoin/bitcoin/pull/8824

  15. laanwj commented at 6:19 PM on March 28, 2017: member

    Yes makes sense I'll just remove them from the header and ignore them for this PR.

    On Mar 28, 2017 7:32 PM, "John Newbery" notifications@github.com wrote:

    Or just refactor them out entirely since they're duplicate code: #8824 https://github.com/bitcoin/bitcoin/pull/8824

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/10095#issuecomment-289845349, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHutvB4r9J2Zyy0H9ZM1oTxiQvWUJbEks5rqUQogaJpZM4MqMwJ .

  16. refactor: Make rest.cpp dependency on `*toJSON` in `blockchain.cpp` explicit f885b67029
  17. laanwj force-pushed on Mar 29, 2017
  18. laanwj commented at 8:02 AM on March 29, 2017: member

    Done, now those two lines remain in rest.cpp, will leave it to another pull to deal with them (I did remove the redundant extern though).

  19. laanwj merged this on Mar 31, 2017
  20. laanwj closed this on Mar 31, 2017

  21. laanwj referenced this in commit 4aa07fa735 on Mar 31, 2017
  22. PastaPastaPasta referenced this in commit b870858d27 on May 10, 2019
  23. PastaPastaPasta referenced this in commit efff2e2829 on May 15, 2019
  24. PastaPastaPasta referenced this in commit 16641e1b1a on May 20, 2019
  25. PastaPastaPasta referenced this in commit c38f210c71 on May 21, 2019
  26. IntegralTeam cross-referenced this on Jun 6, 2019 from issue rpc: Serialize in getblock without cs_main by IntegralTeam
  27. barrystyle referenced this in commit df91e06a28 on Jan 22, 2020
  28. 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-20 06:55 UTC