CConnman: Remove some global usage in the gui #8888

pull theuni wants to merge 2 commits into bitcoin:master from theuni:no-global-connman changing 7 files +65 −50
  1. theuni commented at 3:25 AM on October 5, 2016: member
    • React to the BannedListChanged signal and push down the new list from the clientModel, rather than pulling it the other way
    • Do the same for NoteStats, pushing them down rather than pulling.

    The eventual goal is to contain g_connman in clientModel, at which point we can pass it in and eliminate the global usage.

    The wallet changes that were here originally will show up in a new PR.

  2. fanquake added the label P2P on Oct 5, 2016
  3. laanwj commented at 3:35 AM on October 5, 2016: member

    Concept ACK

  4. dcousens approved
  5. dcousens commented at 5:22 AM on October 5, 2016: contributor

    concept ACK

  6. fanquake commented at 6:53 AM on October 5, 2016: member

    Test failure:

    start_node: RPC succesfully started
    JSONRPC error: Error: Peer-to-peer functionality missing or disabled
    Stopping nodes
    Not cleaning up dir /tmp/testk3xseb1n/41
    Failed
    stderr:
      File "/home/travis/build/bitcoin/bitcoin/qa/rpc-tests/test_framework/test_framework.py", line 148, in main
        self.run_test()
      File "/home/travis/build/bitcoin/bitcoin/build/../qa/rpc-tests/wallet.py", line 208, in run_test
        txIdNotBroadcasted  = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
      File "/home/travis/build/bitcoin/bitcoin/qa/rpc-tests/test_framework/coverage.py", line 49, in __call__
        return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
      File "/home/travis/build/bitcoin/bitcoin/qa/rpc-tests/test_framework/authproxy.py", line 151, in __call__
        raise JSONRPCException(response['error'])
    Pass: False, Duration: 15 s
    
  7. in src/wallet/rpcwallet.cpp:None in ea26e5670e outdated
     345 | @@ -346,7 +346,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
     346 |      if (nValue > curBalance)
     347 |          throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
     348 |  
     349 | -    if (pwalletMain->GetBroadcastTransactions() && !g_connman)
     350 | +    if (!pwalletMain->GetBroadcastTransactions())
    


    MarcoFalke commented at 7:28 AM on October 5, 2016:

    This will now throw the error if -walletbroadcast is turned off?


    MarcoFalke commented at 7:41 AM on October 5, 2016:

    Maybe keep a bool isConnmanMissing() for now?

  8. paveljanik commented at 11:05 AM on October 5, 2016: contributor

    This change results is two new -Wshadow warnings:

    qt/peertablemodel.cpp:62:2445: warning: declaration shadows a local variable [-Wshadow]
    qt/peertablemodel.cpp:74:264: warning: declaration shadows a local variable [-Wshadow]
    
    qt/peertablemodel.cpp:54:49: note: previous declaration is here
        void refreshPeers(QList<CNodeCombinedStats> stats)
    
  9. theuni commented at 6:12 PM on October 5, 2016: member

    Before fixing up here, I'd like to get opinions on an alternate approach to the wallet: https://github.com/theuni/bitcoin/commit/349edab789557db615b29a5869118b4b08c50dab . Note that this was done quickly, it needs to be fixed up for correctness in a few places.

    There, rather than passing the connman instance into the wallet, the wallet loses the ability to relay. Instead, callers are expected to handle relaying themselves. I really like this approach as it removes the p2p layer dependency from the wallet. @jonasschnelli / @laanwj: Thoughts?

  10. MarcoFalke added the label Brainstorming on Oct 6, 2016
  11. MarcoFalke commented at 8:22 AM on October 6, 2016: member

    @theuni Personally I like the new approach better (wallet does not require the connman). Even though this would require some "glue logic" in the caller for sending out the inv, it would reduce the complexity of our "modular" design. For example, it would make error handling easier. Right now the wallet can be seen as a proxy between GUI/RPC and Mempool/p2p. And the wallet needs to handle mempool rejections and pass on the error message to the GUI. (Which it does not do right now as you can see in the code and on irc.)

    So Concept ACK from me on your new suggestion.

  12. theuni commented at 3:23 PM on October 6, 2016: member

    @MarcoFalke Agreed on all points. Notice that with that commit, mempool handling (when recording a new tx) is also pushed out of the wallet, and errors there are handled (albeit awkwardly): https://github.com/theuni/bitcoin/commit/349edab789557db615b29a5869118b4b08c50dab#diff-df7d84ff2f53fcb2a0dc15a3a51e55ceR972 . That error handling seemed funky to me as well, but I wasn't sure how problems would manifest. Thanks for the irc link, looks like we need a distinct "this was not accepted to the mempool" message.

    I think I'll split this up into 2 PRs, so that they don't drag eachother down. I'll leave this one for the qt changes, and create another to remove p2p from the wallet.

  13. theuni force-pushed on Oct 6, 2016
  14. theuni renamed this:
    CConnman: Remove global usage in wallet and some gui
    CConnman: Remove some global usage in the gui
    on Oct 6, 2016
  15. jonasschnelli commented at 3:14 PM on October 8, 2016: contributor

    @theuni: I like the https://github.com/theuni/bitcoin/commit/349edab789557db615b29a5869118b4b08c50dab approach. Maybe we could drive the even further (later): What if the wallet only uses signals to access the conman and the mempool? I'm not entirely sure, but AFAIK we would only need two signals, something ike PushInventoryAllNodes() and bool PushToMemoryPool().

  16. gui: Don't use global connman in bantable 8302a0bcd8
  17. gui: don't use global connman in peertable 9da6613b67
  18. theuni force-pushed on Oct 27, 2016
  19. MarcoFalke added the label GUI on Nov 7, 2016
  20. MarcoFalke removed the label Brainstorming on Nov 7, 2016
  21. MarcoFalke added the label Refactoring on Nov 7, 2016
  22. MarcoFalke commented at 10:11 PM on November 10, 2016: member

    Changed labels, as the scope changed.

    Also, needs rebase again.

    Concept ACK.

  23. jonasschnelli commented at 2:33 PM on November 22, 2016: contributor

    Needs rebase.

  24. jonasschnelli commented at 8:33 AM on January 3, 2017: contributor

    Still needs rebase.

  25. jonasschnelli commented at 1:47 PM on March 17, 2017: contributor

    Closing due to inactivity (feel free to reopen).

  26. jonasschnelli closed this on Mar 17, 2017

  27. theuni commented at 12:51 AM on March 18, 2017: member

    Thanks, will do so soon.

  28. dongcarl commented at 9:32 PM on January 23, 2019: member

    @theuni @jonasschnelli @MarcoFalke

    I would like to take on rebasing this as it is another step towards eliminating globals. Is there anything else that's within scope here that https://github.com/theuni/bitcoin/commit/349edab789557db615b29a5869118b4b08c50dab didn't cover?

  29. ryanofsky commented at 11:12 PM on January 23, 2019: member

    Code here is largely out of date. Pushing network stats to the gui instead of having it query them might be a good idea, though. I don't know enough about the topic to say.

  30. dongcarl moved this from the "In progress" to the "Backlog" column in a project

  31. MarcoFalke locked this on Dec 16, 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-04-18 15:15 UTC

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