aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2019-04-15 13:51:52 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2019-04-15 13:52:17 +0200
commit0c6487c74f8c5ba6de5e4aad44c89be5fbdbe942 (patch)
tree24a0f89940b516418dfc809602742cdb7553835f
parent617261eb1c8beee46e0075d396e4c356ada64593 (diff)
parent41a46cbb31f1622f7d1ff54c7a1c1ca701c1e754 (diff)
Merge #15751: Speed up deriveaddresses for large ranges
41a46cbb31f1622f7d1ff54c7a1c1ca701c1e754 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 utACK 41a46cbb31f1622f7d1ff54c7a1c1ca701c1e754 fanquake: tACK 41a46cb meshcollider: utACK https://github.com/bitcoin/bitcoin/pull/15751/commits/41a46cbb31f1622f7d1ff54c7a1c1ca701c1e754 Tree-SHA512: a1b894ce9d5195d8f9760f44acc6d67a90bb259283fd8c1524c38a222fe53e8c1d35b6653a508b121b7ad91e155c97d26c658f6bdcebf6c360546931e4a26a22
-rw-r--r--src/rpc/misc.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
index f221847347..bfb559f0db 100644
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -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"));
}