doc: update `BroadcastTransaction` comment #29308

pull ismaelsadeeq wants to merge 1 commits into bitcoin:master from ismaelsadeeq:01-2024-clarify-BroadcastTransaction-comment changing 1 files +1 −1
  1. ismaelsadeeq commented at 3:34 PM on January 24, 2024: member

    BroadcastTransaction is also called by submitpackage RPC.

    All transactions that are accepted into the mempool post package processing are broadcasted to peers individually here https://github.com/bitcoin/bitcoin/blob/ea4ddd8652d9dd1e7698e2a6f84c606cf24a2e3e/src/rpc/mempool.cpp#L926

    It's not maintainable to list all the callers of a function.

  2. DrahtBot commented at 3:34 PM on January 24, 2024: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Docs on Jan 24, 2024
  4. ismaelsadeeq renamed this:
    doc: clarify that `BroadcastTransaction` comment
    doc: clarify `BroadcastTransaction` comment
    on Jan 24, 2024
  5. ismaelsadeeq force-pushed on Jan 24, 2024
  6. vasild approved
  7. vasild commented at 3:52 PM on January 24, 2024: contributor

    ACK cca20d94b787d0881a61509445f4827f913e051d

    I was looking at the same comment and was thinking it needs an update. Thanks!

  8. BrandonOdiwuor approved
  9. BrandonOdiwuor commented at 6:47 PM on January 24, 2024: contributor

    lgtm ACK cca20d94b787d0881a61509445f4827f913e051d

  10. kristapsk approved
  11. kristapsk commented at 6:54 PM on January 24, 2024: contributor

    ACK cca20d94b787d0881a61509445f4827f913e051d

  12. willcl-ark approved
  13. willcl-ark commented at 8:47 PM on January 24, 2024: member

    ACK cca20d94b787d0881a61509445f4827f913e051d

  14. in src/node/transaction.cpp:35 in cca20d94b7 outdated
      31 | @@ -32,7 +32,7 @@ static TransactionError HandleATMPError(const TxValidationState& state, std::str
      32 |  
      33 |  TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef tx, std::string& err_string, const CAmount& max_tx_fee, bool relay, bool wait_callback)
      34 |  {
      35 | -    // BroadcastTransaction can be called by either sendrawtransaction RPC or the wallet.
      36 | +    // BroadcastTransaction can be called by sendrawtransaction RPC, submitpackage RPC or the wallet.
    


    stickies-v commented at 11:11 AM on January 25, 2024:

    I don't think we care about which specific RPCs call it? Would just mention that it can be called by RPC, that's the key info - and more maintainable.

        // BroadcastTransaction can be called by RPC or by the wallet.
    

    vasild commented at 11:21 AM on January 25, 2024:

    (this is heading in the direction of "amount of discussion is inversely proportional to the complexity of the change")

    When working on another PR, I found this comment useful and I cared with RPC called the function. Surely there are other means to check who is calling a given function, but this comment gives a quick concise answer at a glance. To be useful it has to be precise and elaborate. If it is vague then it is less useful and it might as well be removed completely.


    stickies-v commented at 11:29 AM on January 25, 2024:

    Extending that logic, should we document all the call sites of each helper function that's used by RPCs because it can be helpful sometimes? That seems abnormal to me. I understood the only relevance of this line to be in relation to the next one: "chainman, mempool and peerman are initialized before the RPC server and wallet are started". For this, it doesn't matter which RPCs call it.


    kristapsk commented at 11:32 AM on January 25, 2024:

    BroadcastTransaction() is not just any helper function, it may irreversibly affect user's privacy.


    ismaelsadeeq commented at 10:44 PM on January 25, 2024:

    I think BroadcastTransaction can be called by RPC or by the wallet is ambiguous in this case. By which RPC?

    BroadcastTransaction can be invoked by other components that will like to submit transactions to the mempool and relay them to peers, in addition to the wallet and RPC. It's accessible through the node interface https://github.com/bitcoin/bitcoin/blob/717103bccec8d271f61f9cd6481b334bd9889146/src/node/interfaces.cpp#L341

    If I understand the rationale behind this comment correctly, it's specifically indicating who is currently calling the function, that is sendrawtransaction, submitpackage RPC, and the wallet

    But if the rationale is indicating the generic meaning of who can invoke BroadcastTransaction, then yes, I agree it would be even more maintainable to simply delete the comment?


    glozow commented at 9:09 AM on January 26, 2024:

    I agree with @stickies-v that listing all the callers of a function within code documentation is not maintainable. This should not be something that a developer relies on and is what a grepper / search bar is for. If it's confusing that not all RPCs are listed, I'd be in favor of just deleting the names of the RPCs that use this function, as it doesn't matter to the comment.


    ismaelsadeeq commented at 9:44 AM on January 26, 2024:

    Deleted the comment, and updated the PR description.


    glozow commented at 4:55 PM on January 26, 2024:

    You've deleted the comment entirely?


    stickies-v commented at 8:55 PM on January 26, 2024:

    I don't understand why we'd delete it entirely either. It belongs together with the next sentence. I suppose it can be deduced from it too, but the current approach doesn't seem like an improvement to me. I still think my suggested phrasing works best from what I've seen so far. I don't think it's ambiguous, it just doesn't specify which RPC is called, which is irrelevant to the rest of the documentation and as such we shouldn't make it look like it isn't.


    ismaelsadeeq commented at 12:10 PM on January 29, 2024:

    Yes I agree with your point. Reverting back with your initial suggestion.

    Thanks @stickies-v

  15. ismaelsadeeq force-pushed on Jan 26, 2024
  16. ismaelsadeeq renamed this:
    doc: clarify `BroadcastTransaction` comment
    doc: update `BroadcastTransaction` comment
    on Jan 26, 2024
  17. shaavan approved
  18. shaavan commented at 12:51 PM on January 26, 2024: contributor

    ACK 437e8eb219c461d27c73a85e0c57d8e11b72a85d

    Following the discussion in the PR so far, I agree that it is more logical and maintainable not to detail which function calls (or can call) a particular function since this information is easily accessible through other methods (e.g. by using an IDE) That's why I think it's best to remove the comment.

  19. DrahtBot requested review from willcl-ark on Jan 26, 2024
  20. DrahtBot requested review from kristapsk on Jan 26, 2024
  21. DrahtBot requested review from vasild on Jan 26, 2024
  22. DrahtBot requested review from BrandonOdiwuor on Jan 26, 2024
  23. DrahtBot removed review request from kristapsk on Jan 26, 2024
  24. DrahtBot removed review request from BrandonOdiwuor on Jan 26, 2024
  25. DrahtBot requested review from kristapsk on Jan 26, 2024
  26. DrahtBot requested review from BrandonOdiwuor on Jan 26, 2024
  27. DrahtBot removed review request from kristapsk on Jan 26, 2024
  28. DrahtBot removed review request from BrandonOdiwuor on Jan 26, 2024
  29. DrahtBot requested review from BrandonOdiwuor on Jan 26, 2024
  30. DrahtBot requested review from kristapsk on Jan 26, 2024
  31. doc: update `BroadcastTransaction` comment
    BroadcastTransaction is also called by submitpackage RPC.
    
    It's not maintainable to list all the callers of a function.
    31cce4a1bd
  32. ismaelsadeeq force-pushed on Jan 29, 2024
  33. stickies-v approved
  34. stickies-v commented at 12:54 PM on January 29, 2024: contributor

    ACK 31cce4a1bdbb48f57996615ee6c686e456cc0bea

  35. DrahtBot removed review request from BrandonOdiwuor on Jan 29, 2024
  36. DrahtBot removed review request from kristapsk on Jan 29, 2024
  37. DrahtBot requested review from shaavan on Jan 29, 2024
  38. DrahtBot requested review from BrandonOdiwuor on Jan 29, 2024
  39. DrahtBot requested review from kristapsk on Jan 29, 2024
  40. kristapsk approved
  41. kristapsk commented at 1:09 PM on January 29, 2024: contributor

    ACK 31cce4a1bdbb48f57996615ee6c686e456cc0bea

  42. DrahtBot removed review request from shaavan on Jan 29, 2024
  43. DrahtBot removed review request from BrandonOdiwuor on Jan 29, 2024
  44. DrahtBot requested review from BrandonOdiwuor on Jan 29, 2024
  45. DrahtBot requested review from shaavan on Jan 29, 2024
  46. naumenkogs approved
  47. naumenkogs commented at 9:04 AM on January 30, 2024: member

    ACK 31cce4a1bdbb48f57996615ee6c686e456cc0bea

  48. DrahtBot removed review request from BrandonOdiwuor on Jan 30, 2024
  49. DrahtBot removed review request from shaavan on Jan 30, 2024
  50. DrahtBot requested review from BrandonOdiwuor on Jan 30, 2024
  51. DrahtBot requested review from shaavan on Jan 30, 2024
  52. glozow merged this on Jan 30, 2024
  53. glozow closed this on Jan 30, 2024

  54. ismaelsadeeq deleted the branch on Jun 27, 2024
  55. PastaPastaPasta referenced this in commit 0e2893a689 on Oct 24, 2024
  56. PastaPastaPasta referenced this in commit 5045b35a96 on Oct 24, 2024
  57. PastaPastaPasta referenced this in commit 3599458cd7 on Oct 24, 2024
  58. PastaPastaPasta referenced this in commit 8bf1d06599 on Oct 24, 2024
  59. PastaPastaPasta referenced this in commit a67319351a on Oct 24, 2024
  60. bitcoin locked this on Jun 27, 2025

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-22 18:13 UTC

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