rpc: Register calls where they are defined #7766

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2016_03_separate_rpc_registration changing 15 files +165 −137
  1. laanwj commented at 6:05 PM on March 29, 2016: member

    Split out registration of methods to every module, apart from 'help' and 'stop' which are implemented in rpcserver.cpp itself.

    • This makes it easier to add or remove RPC commands - no longer everything that includes rpcserver.h has to be rebuilt when there's a change there.
    • Cleans up rpc/server.h by getting rid of the huge cluttered list of function definitions.
    • Removes most of the bitcoin-specific code from rpcserver.cpp and .h.

    Continues #7307 for the non-wallet.

  2. laanwj added the label RPC/REST/ZMQ on Mar 29, 2016
  3. laanwj force-pushed on Mar 29, 2016
  4. laanwj added the label Refactoring on Mar 29, 2016
  5. jonasschnelli commented at 6:15 PM on March 29, 2016: contributor

    Nice! Concept ACK.

  6. MarcoFalke commented at 6:18 PM on March 29, 2016: member

    Concept ACK. Would it make sense to get rid of the duplicate code in void Register*()?

  7. laanwj commented at 7:10 AM on March 30, 2016: member

    Would it make sense to get rid of the duplicate code in void Register*()?

    Maybe. I thought about it, but it's only a simple loop of four lines, sometimes factoring something so simple out to a function makes things harder to understand, not easier. Another option would be to export a 'descriptor structure' with a name, pointer to the array, and size of the array. E.g. like Linux modules. But simply having Register* function leaves it up to the module as to how to determine what to register (e.g. there may be optional features enabled on the command line).

  8. jonasschnelli commented at 9:30 AM on March 30, 2016: contributor

    IMO we should keep the array loop as it is (and not refactor with some hard-to-understand macro-like optimization).

  9. laanwj commented at 10:07 AM on March 30, 2016: member

    Could make it two lines, even, without losing any clarity:

       for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
            tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
    

    (will update the one in rpcwallet as well)

  10. CodeShark commented at 10:51 AM on March 30, 2016: contributor

    Concept ACK

  11. sipa commented at 11:47 AM on March 30, 2016: member

    Concept ACK, though I wonder if it wouldn't be cleaner to pass a pointer to tableRPC to the registration commands, so the individual RPC implementations don't even need to depend on access to the global?

  12. laanwj commented at 11:58 AM on March 30, 2016: member

    pass a pointer to tableRPC to the registration commands

    Awesome idea, will do that.

  13. sipa commented at 3:56 PM on March 30, 2016: member

    utACK 3be52e1

  14. dcousens commented at 1:00 AM on March 31, 2016: contributor

    utACK 3be52e1

  15. rpc: Register calls where they are defined
    Split out methods to every module, apart from 'help' and 'stop' which
    are implemented in rpcserver.cpp itself.
    
    - This makes it easier to add or remove RPC commands - no longer everything that includes
        rpcserver.h has to be rebuilt when there's a change there.
    - Cleans up `rpc/server.h` by getting rid of the huge cluttered list of function definitions.
    - Removes most of the bitcoin-specific code from rpcserver.cpp and .h.
    
    Continues #7307 for the non-wallet.
    fb8a8cf2e6
  16. laanwj commented at 8:48 AM on March 31, 2016: member

    Squashed a20fca9 0b18725 dcb0a76 3be52e1 into fb8a8cf

  17. laanwj force-pushed on Mar 31, 2016
  18. laanwj merged this on Mar 31, 2016
  19. laanwj closed this on Mar 31, 2016

  20. laanwj referenced this in commit 16555b658f on Mar 31, 2016
  21. laanwj cross-referenced this on Apr 6, 2016 from issue Add cursor to iterate over utxo set, use this in `gettxoutsetinfo` by laanwj
  22. sickpig cross-referenced this on Feb 22, 2017 from issue Bundle together deadalnix's PR 213 to 218 by sickpig
  23. codablock referenced this in commit 9c83fd9148 on Sep 16, 2017
  24. codablock referenced this in commit 37c2e89ec0 on Sep 19, 2017
  25. codablock referenced this in commit dd9779241a on Dec 9, 2017
  26. codablock referenced this in commit 0265716e4e on Dec 19, 2017
  27. codablock referenced this in commit 644240157a on Dec 19, 2017
  28. dagurval cross-referenced this on Feb 12, 2018 from issue rpc: Register calls where they are defined by dagurval
  29. str4d cross-referenced this on Jun 20, 2018 from issue RPC code refactor by str4d
  30. zkbot referenced this in commit 52f4abccef on Jun 20, 2018
  31. zkbot referenced this in commit ec246b2ec1 on Jul 3, 2018
  32. zkbot referenced this in commit b8e82e77af on Jul 16, 2018
  33. zkbot referenced this in commit 5978dfecb5 on Jul 18, 2018
  34. zkbot referenced this in commit cd0484e023 on Jul 18, 2018
  35. furszy cross-referenced this on Jun 23, 2020 from issue [RPC] Table registration update and wallet table decoupled. by furszy
  36. Liquid369 cross-referenced this on Jun 28, 2020 from issue [RPC] Register calls where they are defined by Liquid369
  37. Liquid369 cross-referenced this on Jun 30, 2020 from issue [RPC] Register calls where they are defined by Liquid369
  38. random-zebra referenced this in commit 7a849ca06a on Jul 1, 2020
  39. Fuzzbawls cross-referenced this on Oct 17, 2020 from issue [RPC][Refactor] Register calls where they are defined by Fuzzbawls
  40. random-zebra referenced this in commit ab460a523f on Oct 30, 2020
  41. 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