mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 08:44:02 +02:00
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: ACK55b931934aTree-SHA512: 4a7fdbcbb4e55bd034e9cf28ab4e7ee3fb1745fc8847adb388c98a19c952a1fb66d7b54f0f28b4c2a75a42473923742b4a99fb26771577183a98e0bcbf87a8ca
This commit is contained in:
@@ -54,8 +54,8 @@ static void WalletIsMine(benchmark::Bench& bench, bool legacy_wallet, int num_co
|
||||
std::string error;
|
||||
std::vector<std::unique_ptr<Descriptor>> desc = Parse("combo(" + EncodeSecret(key) + ")", keys, error, /*require_checksum=*/false);
|
||||
WalletDescriptor w_desc(std::move(desc.at(0)), /*creation_time=*/0, /*range_start=*/0, /*range_end=*/0, /*next_index=*/0);
|
||||
auto spkm = wallet->AddWalletDescriptor(w_desc, keys, /*label=*/"", /*internal=*/false);
|
||||
assert(spkm);
|
||||
auto spk_manager = *Assert(wallet->AddWalletDescriptor(w_desc, keys, /*label=*/"", /*internal=*/false));
|
||||
assert(spk_manager);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user