diff options
| author | Riccardo Spagni <ric@spagni.net> | 2018-05-21 20:55:02 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2018-05-21 20:55:02 +0200 |
| commit | 2a1e23e0873d859b9359aa17cff591b86993bd8f (patch) | |
| tree | 0236964fb6c1b7116e81ce9686e661d264a620d6 /src/rpc/core_rpc_server.cpp | |
| parent | 2f5506daf874ddfc3cfdf9de94c65daef924d29a (diff) | |
| parent | 5f8ffca34d87e46b7a44964e61733bfe5a85c028 (diff) | |
| download | monzero-core-2a1e23e0873d859b9359aa17cff591b86993bd8f.tar.gz monzero-core-2a1e23e0873d859b9359aa17cff591b86993bd8f.tar.xz monzero-core-2a1e23e0873d859b9359aa17cff591b86993bd8f.zip | |
Merge pull request #3814
5f8ffca3 speed up get_output_distribution (and precalc common case) (moneromooo-monero)
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
| -rw-r--r-- | src/rpc/core_rpc_server.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 3645c494e..e28914d96 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -47,6 +47,7 @@ using namespace epee; #include "rpc/rpc_args.h" #include "core_rpc_server_error_codes.h" #include "p2p/net_node.h" +#include "get_output_distribution_cache.h" #include "version.h" #undef MONERO_DEFAULT_LOG_CATEGORY @@ -2103,9 +2104,23 @@ namespace cryptonote continue; } + // this is a slow operation, so we have precomputed caches of common cases + bool found = false; + for (const auto &slot: get_output_distribution_cache) + { + if (slot.amount == amount && slot.from_height == req.from_height && slot.to_height == req.to_height) + { + res.distributions.push_back({amount, slot.start_height, slot.distribution, slot.base}); + found = true; + break; + } + } + if (found) + continue; + std::vector<uint64_t> distribution; uint64_t start_height, base; - if (!m_core.get_output_distribution(amount, req.from_height, start_height, distribution, base)) + if (!m_core.get_output_distribution(amount, req.from_height, req.to_height, start_height, distribution, base)) { error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; error_resp.message = "Failed to get rct distribution"; |
