Merge bitcoin/bitcoin#32023: wallet: removed duplicate call to GetDescriptorScriptPubKeyMan
55b931934aremoved duplicate calling of GetDescriptorScriptPubKeyMan (Saikiran) Pull request description: Removed duplicate call to GetDescriptorScriptPubKeyMan and Instead of checking linearly I have used find method so time complexity reduced significantly for GetDescriptorScriptPubKeyMan after this fix improved performance of importdescriptor part refs https://github.com/bitcoin/bitcoin/issues/32013. **Steps to reproduce in testnet environment** **Input size:** 2 million address in the wallet **Step1:** call importaddresdescriptor rpc method observe the time it has taken. **With the provided fix:** Do the same steps again observe the time it has taken. There is a huge improvement in the performance. (previously it may take 5 to 6 seconds now it will take 1 seconds or less) main changes i've made during this pr: 1. remove duplicate call to GetDescriptorScriptPubKeyMan method 2. And inside GetDescriptorScriptPubKeyMan method previously we checking **each address linearly** so each time it is calling HasWallet method which has aquired lock. 3. Now i've modified this logic call **find method on the map (O(logn)**) time it is taking, so only once we calling HasWallet method. **Note:** Smaller inputs in the wallet you may not see the issue but huge wallet size it will definitely impact the performance. ACKs for top commit: achow101: ACK55b931934aw0xlt: ACK https://github.com/bitcoin/bitcoin/pull/32023/commits/55b931934a34bab11446e8eed7bdaef92bb056de Tree-SHA512: 4a7fdbcbb4e55bd034e9cf28ab4e7ee3fb1745fc8847adb388c98a19c952a1fb66d7b54f0f28b4c2a75a42473923742b4a99fb26771577183a98e0bcbf87a8ca
This commit is contained in:
12 files changed
+45
-29
No files matched your search
@@ -223,7 +223,8 @@ std::shared_ptr<CWallet> SetupDescriptorsWallet(interfaces::Node& node, TestChai
|
||||
assert(descs.size() == 1);
|
||||
auto& desc = descs.at(0);
|
||||
WalletDescriptor w_desc(std::move(desc), 0, 0, 1, 1);
|
||||
if (!wallet->AddWalletDescriptor(w_desc, provider, "", false)) assert(false);
|
||||
auto spk_manager = *Assert(wallet->AddWalletDescriptor(w_desc, provider, "", false));
|
||||
assert(spk_manager);
|
||||
CTxDestination dest = GetDestinationForKey(test.coinbaseKey.GetPubKey(), wallet->m_default_address_type);
|
||||
wallet->SetAddressBook(dest, "", wallet::AddressPurpose::RECEIVE);
|
||||
wallet->SetLastBlockProcessed(105, WITH_LOCK(node.context()->chainman->GetMutex(), return node.context()->chainman->ActiveChain().Tip()->GetBlockHash()));
|
||||
|
||||
Reference in new issue
Block a user