multiprocess: Add interfaces::Node::broadCastTransaction method #23499

pull ryanofsky wants to merge 1 commits into bitcoin:master from ryanofsky:pr/ipc-broadcast changing 3 files +10 −2
  1. ryanofsky commented at 8:42 pm on November 12, 2021: member

    This fixes a null pointer crash in the bitcoin-gui PSBT dialog. The bitcoin-gui interfaces::Node object has a null NodeContext pointer, and can’t broadcast transactions directly. It needs to broadcast transactions through the bitcoin-node process instead.


    This PR is part of the process separation project.

  2. multiprocess: Add interfaces::Node::broadCastTransaction method
    This fixes a null pointer crash in the bitcoin-gui PSBT dialog. The
    bitcoin-gui interfaces::Node object has a null NodeContext pointer, and
    can't broadcast transactions directly. It needs to broadcast
    transactions through the bitcoin-node process instead.
    0e0f4fdd89
  3. DrahtBot added the label GUI on Nov 12, 2021
  4. DrahtBot added the label interfaces on Nov 12, 2021
  5. DrahtBot commented at 1:22 am on November 13, 2021: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #22981 (doc: Fix incorrect C++ named args by MarcoFalke)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  6. lsilva01 approved
  7. lsilva01 commented at 9:06 pm on November 13, 2021: contributor
    Code Review ACK 0e0f4fd
  8. MarcoFalke removed the label GUI on Nov 14, 2021
  9. MarcoFalke commented at 7:34 am on November 14, 2021: member
    Seems dangerous to call a test-only method context, a name that implies it can be used in production code. Wouldn’t it be better to pick an ugly name like getMockedContext or getTestContext?
  10. MarcoFalke added the label Refactoring on Nov 14, 2021
  11. ryanofsky commented at 2:18 am on November 16, 2021: member

    Seems dangerous to call a test-only method context, a name that implies it can be used in production code. Wouldn’t it be better to pick an ugly name like getMockedContext or getTestContext?

    I don’t really consider it a test-only method. The method is only currently used from tests, but it’s not returning a fake context, and I think it could be legitimately be called outside of tests. For example, the current code calling this method works because the method returns the real working context pointer. The problem just happens after #10102, because the code calling it is not checking for null, and #10102 makes the method start to return null if the node is out-of-process. The method could be legitimately used in other cases to enable or disable features depending on whether the node is in-process, or change GUI behavior to deal with latency or overhead.

    I guess I’d prefer not to rename the method, but would reconsider it or move it to a friend class if it causes more problems. This is actually the first time I’ve seen the method misused any time, and it has been around a little while.

  12. MarcoFalke commented at 7:42 am on November 16, 2021: member
    In that case the “Useful for testing” docstring can be removed? Any function is “Useful for testing” if it is called by the tests.
  13. MarcoFalke merged this on Nov 16, 2021
  14. MarcoFalke closed this on Nov 16, 2021

  15. sidhujag referenced this in commit 1ea0cd0671 on Nov 16, 2021
  16. ryanofsky commented at 7:41 pm on November 16, 2021: member

    In that case the “Useful for testing” docstring can be removed? Any function is “Useful for testing” if it is called by the tests.

    I guess I would replace “Useful for testing” with “Mostly useful for testing” because like you say any function can be useful for testing. But the point of these short method descriptions is to help narrow down what methods you may want to call when you are writing code, and “mostly useful for testing” should be a good hint that calling this is useful when you are writing test code and need to access state, and a hint that this is probably not what you need otherwise. If the documentation is a problem, it could explicitly go on to say that the method can return null and callers should check for nulls. But this won’t return null after #10102, and if there is actually another problem here I would look into a more solid protection like moving the method it to a friend class than trying to do something with documentation.

  17. ryanofsky added this to the "Done" column in a project

  18. DrahtBot locked this on Nov 17, 2022

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-21 15:12 UTC

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