aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-05-31 16:53:56 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-05-31 16:54:57 +0100
commitd3447364d0373dfe3dbb502ade37060649c7bad6 (patch)
tree959ce8c073aa57021b4335a6eb5e69daabce8ad9 /src/rpc
parentMerge pull request #3251 (diff)
downloadmonero-d3447364d0373dfe3dbb502ade37060649c7bad6.tar.xz
rpc: convert distribution to cumulative after caching
This avoids double conversion on a later cache hit
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index b5ef2557a..d7a785600 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -2117,12 +2117,6 @@ namespace cryptonote
if (offset <= req.to_height && req.to_height - offset + 1 < distribution.size())
distribution.resize(req.to_height - offset + 1);
}
- if (req.cumulative)
- {
- distribution[0] += base;
- for (size_t n = 1; n < distribution.size(); ++n)
- distribution[n] += distribution[n-1];
- }
if (amount == 0)
{
@@ -2134,6 +2128,13 @@ namespace cryptonote
d.cached = true;
}
+ if (req.cumulative)
+ {
+ distribution[0] += base;
+ for (size_t n = 1; n < distribution.size(); ++n)
+ distribution[n] += distribution[n-1];
+ }
+
res.distributions.push_back({amount, start_height, std::move(distribution), base});
}
}