mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
tx handler
This commit is contained in:
@@ -1534,3 +1534,37 @@ getLedger(
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
std::optional<LedgerRange>
|
||||
getLedgerRange(std::shared_ptr<PgPool>& pgPool)
|
||||
{
|
||||
auto range = PgQuery(pgPool)("SELECT complete_ledgers()");
|
||||
if (!range)
|
||||
return {};
|
||||
|
||||
std::string res{range.c_str()};
|
||||
try
|
||||
{
|
||||
size_t minVal = 0;
|
||||
size_t maxVal = 0;
|
||||
if (res == "empty" || res == "error" || res.empty())
|
||||
return {};
|
||||
else if (size_t delim = res.find('-'); delim != std::string::npos)
|
||||
{
|
||||
minVal = std::stol(res.substr(0, delim));
|
||||
maxVal = std::stol(res.substr(delim + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
minVal = maxVal = std::stol(res);
|
||||
}
|
||||
return LedgerRange{minVal, maxVal};
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(error)
|
||||
<< __func__ << " : "
|
||||
<< "Error parsing result of getCompleteLedgers()";
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user