mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 01:12:39 +00:00
rpc: speed up the common get_output_distribution case while syncing
This commit is contained in:
parent
58ce16d4d9
commit
5ca4994c9c
1 changed files with 19 additions and 2 deletions
|
@ -43,8 +43,25 @@ namespace rpc
|
||||||
|
|
||||||
std::vector<std::uint64_t> distribution;
|
std::vector<std::uint64_t> distribution;
|
||||||
std::uint64_t start_height, base;
|
std::uint64_t start_height, base;
|
||||||
if (!f(amount, from_height, to_height, start_height, distribution, base))
|
|
||||||
return boost::none;
|
// see if we can extend the cache - a common case
|
||||||
|
if (d.cached && amount == 0 && d.cached_from == from_height && to_height > d.cached_to)
|
||||||
|
{
|
||||||
|
std::vector<std::uint64_t> new_distribution;
|
||||||
|
if (!f(amount, d.cached_to + 1, to_height, start_height, new_distribution, base))
|
||||||
|
return boost::none;
|
||||||
|
distribution = d.cached_distribution;
|
||||||
|
distribution.reserve(distribution.size() + new_distribution.size());
|
||||||
|
for (const auto &e: new_distribution)
|
||||||
|
distribution.push_back(e);
|
||||||
|
start_height = d.cached_start_height;
|
||||||
|
base = d.cached_base;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!f(amount, from_height, to_height, start_height, distribution, base))
|
||||||
|
return boost::none;
|
||||||
|
}
|
||||||
|
|
||||||
if (to_height > 0 && to_height >= from_height)
|
if (to_height > 0 && to_height >= from_height)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue