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. jonasschnelli commented at 1:27 pm on March 27, 2017: contributor
    utACK e6dcfeec05d6527ab148550836937ff435e6449c
  5. laanwj commented at 2:05 pm on March 27, 2017: member
    @jnewbery Done
  6. laanwj commented at 2:07 pm on March 27, 2017: member

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

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

    Going to add them to the header as well.

  7. refactor: Move RPCNotifyBlockChange out of `rpc/server.h` 8d8f28dd52
  8. laanwj force-pushed on Mar 27, 2017
  9. jnewbery commented at 3:07 pm on March 27, 2017: member
    Looks good to me. Tested ACK c7e9aa7c1a92adba141958e5f86d267f34cc9508
  10. dcousens approved
  11. 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.

  12. laanwj commented at 5:11 pm on March 28, 2017: member
    @jtimon Good catch. I’ll move them to their own header.
  13. 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
  14. 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 .

  15. refactor: Make rest.cpp dependency on `*toJSON` in `blockchain.cpp` explicit f885b67029
  16. laanwj force-pushed on Mar 29, 2017
  17. 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).
  18. laanwj merged this on Mar 31, 2017
  19. laanwj closed this on Mar 31, 2017

  20. laanwj referenced this in commit 4aa07fa735 on Mar 31, 2017
  21. PastaPastaPasta referenced this in commit b870858d27 on May 10, 2019
  22. PastaPastaPasta referenced this in commit efff2e2829 on May 15, 2019
  23. PastaPastaPasta referenced this in commit 16641e1b1a on May 20, 2019
  24. PastaPastaPasta referenced this in commit c38f210c71 on May 21, 2019
  25. barrystyle referenced this in commit df91e06a28 on Jan 22, 2020
  26. MarcoFalke 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: 2024-11-17 15:12 UTC

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