Split event handlers by wallet #13070

pull promag wants to merge 1 commits into bitcoin:master from promag:2018-04-split-handlers-by-wallet changing 2 files +8 −7
  1. promag commented at 12:01 AM on April 25, 2018: member

    Currently it's not possible to disconnect an event handler of a particular wallet. With this change, event handlers are associated with the corresponding wallet. It is then possible to disconnect all handlers of a particular wallet. There is no behavior change. This is a small step towards dynamic wallet unloading.

  2. promag commented at 12:02 AM on April 25, 2018: member

    @ryanofsky care to review?

  3. fanquake added the label GUI on Apr 25, 2018
  4. promag force-pushed on Apr 25, 2018
  5. promag force-pushed on Apr 25, 2018
  6. ryanofsky commented at 1:02 AM on April 25, 2018: member

    @ryanofsky care to review?

    Change seems harmless but I don't understand why it makes sense. Is it part of a larger set of changes that I can look at or part of a larger design that you can describe somewhere?

    The map doesn't seem to make sense for unloading because wallet interfaces are created on the fly and you can't identify them by pointer. Maybe the map is supposed to be keyed by wallet name? The list of handlers doesn't seem to make sense because there is only one handler. I also think it would probably be better and less duplicative if splashscreen were not managing any interface pointers at all, but just creating a slot which wallets in m_wallet_models could send signals to.

  7. promag commented at 9:17 PM on April 25, 2018: member

    Thanks @ryanofsky for the feedback.

    I also think it would probably be better and less duplicative if splashscreen were not managing any interface pointers at all

    The subscribeToCoreSignals/unsubscribeFromCoreSignals is used in several places. I can remove it from splash screen but let's discuss it a different PR or IRL.

    you can't identify them by pointer

    The list of handlers doesn't seem to make sense because there is only one handler

    Consider the following example:

    
    void SplashScreen::ConnectWallet(std::unique_ptr<interfaces::Wallet> wallet)
    {
        auto i = m_connected_wallets.emplace(std::move(wallet), std::list<std::unique_ptr<interfaces::Handler>>()).first;
        i->second.emplace_back(wallet->handleShowProgress(boost::bind(ShowProgress, this, _1, _2, false)));
        i->second.emplace_back(wallet->handleAboutToRemove([this, i]() {
            for (auto& handler : i->second) {
                handler->disconnect();
            }
            m_connected_wallets.erase(i);
        }));
    }
    

    Which uses the iterator i in the callback. With this example does it make more sense?

    Note that map iterators aren't invalidated after insertions or erasures, so this is safe.

    Maybe the map is supposed to be keyed by wallet name?

    Maybe, I don't know if that's acceptable.

  8. ryanofsky commented at 9:46 PM on April 25, 2018: member

    With this example does it make more sense?

    No, because there is no map lookup. It would seem more appropriate to use list<<pair<>> instead of map<> if there are no lookups comparing map keys. But it is hard to evaluate this when there is no description of the overall design motivating this change and no justification for why a splash screen wallet data structure should exist at all.

    I don't think I can productively review these small factoring PRs without some kind of description of the larger picture they fit into. If it is not possible to describe smaller refactoring changes coherently, I'd prefer to just look at a larger PR or branch which implements real functionality, so I can understand how the changes fit together.

  9. ui: Split event handlers by wallet 4bddc84efa
  10. promag force-pushed on Apr 26, 2018
  11. promag commented at 9:51 PM on April 28, 2018: member

    @ryanofsky thanks for the insights.

    I'd prefer to just look at a larger PR

    please see #13111.

  12. promag closed this on Apr 28, 2018

  13. promag deleted the branch on Apr 28, 2018
  14. MarcoFalke locked this on Sep 8, 2021
Contributors
Labels

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

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