mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-02 17:45:57 +00:00
add upper bound to time spent in fetchLedgerPage
This commit is contained in:
@@ -196,6 +196,7 @@ BackendInterface::fetchLedgerPage(
|
|||||||
uint32_t adjustedLimit = std::max(limitHint, std::max(limit, (uint32_t)4));
|
uint32_t adjustedLimit = std::max(limitHint, std::max(limit, (uint32_t)4));
|
||||||
LedgerPage page;
|
LedgerPage page;
|
||||||
page.cursor = cursor;
|
page.cursor = cursor;
|
||||||
|
long totalTime = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
adjustedLimit = adjustedLimit >= 8192 ? 8192 : adjustedLimit * 2;
|
adjustedLimit = adjustedLimit >= 8192 ? 8192 : adjustedLimit * 2;
|
||||||
@@ -207,18 +208,18 @@ BackendInterface::fetchLedgerPage(
|
|||||||
page.cursor ? ripple::strHex(*page.cursor) : "";
|
page.cursor ? ripple::strHex(*page.cursor) : "";
|
||||||
std::string partialCursorStr =
|
std::string partialCursorStr =
|
||||||
partial.cursor ? ripple::strHex(*partial.cursor) : "";
|
partial.cursor ? ripple::strHex(*partial.cursor) : "";
|
||||||
|
auto thisTime =
|
||||||
|
std::chrono::duration_cast<std::chrono::milliseconds>(end - start)
|
||||||
|
.count();
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
BOOST_LOG_TRIVIAL(debug)
|
||||||
<< __func__ << " " << std::to_string(ledgerSequence) << " "
|
<< __func__ << " " << std::to_string(ledgerSequence) << " "
|
||||||
<< std::to_string(adjustedLimit) << " " << pageCursorStr << " - "
|
<< std::to_string(adjustedLimit) << " " << pageCursorStr << " - "
|
||||||
<< partialCursorStr << " - time = "
|
<< partialCursorStr << " - time = " << std::to_string(thisTime);
|
||||||
<< std::to_string(
|
totalTime += thisTime;
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
||||||
end - start)
|
|
||||||
.count());
|
|
||||||
page.objects.insert(
|
page.objects.insert(
|
||||||
page.objects.end(), partial.objects.begin(), partial.objects.end());
|
page.objects.end(), partial.objects.begin(), partial.objects.end());
|
||||||
page.cursor = partial.cursor;
|
page.cursor = partial.cursor;
|
||||||
} while (page.objects.size() < limit && page.cursor);
|
} while (page.objects.size() < limit && page.cursor && totalTime < 5000);
|
||||||
if (incomplete)
|
if (incomplete)
|
||||||
{
|
{
|
||||||
auto rng = fetchLedgerRange();
|
auto rng = fetchLedgerRange();
|
||||||
|
|||||||
Reference in New Issue
Block a user