wallet: remove GetScriptPubKeyMan spam #21880

pull klementtan wants to merge 1 commits into bitcoin:master from klementtan:GetScriptPubKeyMan-spam changing 1 files +14 −9
  1. klementtan commented at 4:57 pm on May 7, 2021: contributor

    fixes: #21716

    Problem: In AddWalletDescriptor we iterate through every combination of internal/external and OutputType. For each combination we call GetScriptPubKeyMan and when the combination is invalid we would log a warning scriptPubKey Manager for output type and thus causing the spam in the logs.

    My approach Since there is only one ScriptPubKeyMan that has the same id as old_spk_man_id, we would instead iterate through both the map and erase the ScriptPubKeyMan once we find it.

    The code that causes the spam: src/wallet/wallet.cpp

     0ScriptPubKeyMan* CWallet::GetScriptPubKeyMan(const OutputType& type, bool internal) const
     1{
     2    const std::map<OutputType, ScriptPubKeyMan*>& spk_managers = internal ? m_internal_spk_managers : m_external_spk_managers;
     3    std::map<OutputType, ScriptPubKeyMan*>::const_iterator it = spk_managers.find(type);
     4    if (it == spk_managers.end()) {
     5        WalletLogPrintf("%s scriptPubKey Manager for output type %d does not exist\n", internal ? "Internal" : "External", static_cast<int>(type));
     6        return nullptr;
     7    }
     8    return it->second;
     9}
    10        auto old_spk_man_id = old_spk_man->GetID();
    11        for (bool internal : {false, true}) {
    12            for (OutputType t : OUTPUT_TYPES) {
    13                auto active_spk_man = GetScriptPubKeyMan(t, internal);
    14                if (active_spk_man && active_spk_man->GetID() == old_spk_man_id) {
    15                    if (internal) {
    16                        m_internal_spk_managers.erase(t);
    17                    } else {
    18                        m_external_spk_managers.erase(t);
    19                    }
    20                    break;
    21                }
    22            }
    23        }
    
  2. wallet: remove GetScriptPubKeyMan spam 87ce05c619
  3. Subawit approved
  4. DrahtBot added the label Wallet on May 7, 2021
  5. DrahtBot commented at 9:36 pm on May 7, 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:

    • #19651 (wallet: importdescriptors update existing by S3RK)

    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. fanquake requested review from achow101 on May 8, 2021
  7. fanquake requested review from meshcollider on May 8, 2021
  8. fanquake commented at 2:50 am on May 8, 2021: member
    @S3RK You might be interested in this.
  9. 0racl3z approved
  10. S3RK commented at 7:08 pm on May 10, 2021: member
    Updating descriptors by removing SPKmanager from the map and creating a new one has been shown to be problematic — see #19651. I’d suggest to review #19651 as it removes the code it question altogether and it had one ACK already.
  11. achow101 commented at 8:44 pm on May 10, 2021: member
    Agree with @S3RK that we should focus on #19651 which removes this code and replaces it with proper updating that also happens to not call GetScriptPubKeyMan a bunch.
  12. fanquake commented at 10:55 pm on May 10, 2021: member
    Going to close this in favour of #19651. @klementtan would you like to review that PR instead?
  13. fanquake closed this on May 10, 2021

  14. klementtan commented at 0:05 am on May 11, 2021: contributor
    Agreed. #19651 is a better solution than this. Will take a look at it.
  15. fanquake deleted a comment on May 11, 2021
  16. fanquake deleted a comment on May 11, 2021
  17. fanquake locked this on May 11, 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-17 03:12 UTC

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