mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 04:12:36 -03:00
Merge #15751: Speed up deriveaddresses for large ranges
41a46cbb31
Speed up deriveaddresses for large ranges (Pieter Wuille) Pull request description: `deriveaddresses` dumps all generated addresses into a single `FlatSigningProvider`, which is also used for looking up information for future derivations. @achow101 points out that the growing data structures may unnecessary increase lookup time for later derivations. Fix this by separating the provider used for lookups (`key_provider`) and the one we dump things into. This gives a 10x speedup for a range of 7000 elements, and probably a larger speedup for larger ranges. ACKs for commit 41a46c: achow101: Regardless, I do think this is a good change, so utACK41a46cbb31
fanquake: tACK41a46cb
meshcollider: utACK41a46cbb31
Tree-SHA512: a1b894ce9d5195d8f9760f44acc6d67a90bb259283fd8c1524c38a222fe53e8c1d35b6653a508b121b7ad91e155c97d26c658f6bdcebf6c360546931e4a26a22
This commit is contained in:
commit
0c6487c74f
1 changed files with 4 additions and 3 deletions
|
@ -229,8 +229,8 @@ UniValue deriveaddresses(const JSONRPCRequest& request)
|
|||
range_end = range.second;
|
||||
}
|
||||
|
||||
FlatSigningProvider provider;
|
||||
auto desc = Parse(desc_str, provider, /* require_checksum = */ true);
|
||||
FlatSigningProvider key_provider;
|
||||
auto desc = Parse(desc_str, key_provider, /* require_checksum = */ true);
|
||||
if (!desc) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor"));
|
||||
}
|
||||
|
@ -246,8 +246,9 @@ UniValue deriveaddresses(const JSONRPCRequest& request)
|
|||
UniValue addresses(UniValue::VARR);
|
||||
|
||||
for (int i = range_begin; i <= range_end; ++i) {
|
||||
FlatSigningProvider provider;
|
||||
std::vector<CScript> scripts;
|
||||
if (!desc->Expand(i, provider, scripts, provider)) {
|
||||
if (!desc->Expand(i, key_provider, scripts, provider)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Cannot derive script without private keys"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue