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:

    0   for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
    1        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. codablock referenced this in commit 9c83fd9148 on Sep 16, 2017
  22. codablock referenced this in commit 37c2e89ec0 on Sep 19, 2017
  23. codablock referenced this in commit dd9779241a on Dec 9, 2017
  24. codablock referenced this in commit 0265716e4e on Dec 19, 2017
  25. codablock referenced this in commit 644240157a on Dec 19, 2017
  26. zkbot referenced this in commit 52f4abccef on Jun 20, 2018
  27. zkbot referenced this in commit ec246b2ec1 on Jul 3, 2018
  28. zkbot referenced this in commit b8e82e77af on Jul 16, 2018
  29. zkbot referenced this in commit 5978dfecb5 on Jul 18, 2018
  30. zkbot referenced this in commit cd0484e023 on Jul 18, 2018
  31. random-zebra referenced this in commit 7a849ca06a on Jul 1, 2020
  32. random-zebra referenced this in commit ab460a523f on Oct 30, 2020
  33. 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-22 15:12 UTC

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