rpc: convert distribution to cumulative after caching

This avoids double conversion on a later cache hit
This commit is contained in:
moneromooo-monero 2018-05-31 16:53:56 +01:00 committed by wowario
parent 7b033b1670
commit 36deb5d509
No known key found for this signature in database
GPG key ID: 24DCBE762DE9C111

View file

@ -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});
}
}