Address code review feedback: retry loop, comment cleanup, error code improvements

Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/629eace2-9c23-40d9-89f5-9ef3099cdf14

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-24 18:42:23 +00:00
committed by GitHub
parent 5e6d8a4692
commit 9a221d1291
4 changed files with 19 additions and 7 deletions

View File

@@ -35,7 +35,7 @@ getFileContents(
if (!fileStream)
{
ec = make_error_code(static_cast<std::errc>(errno));
ec.assign(errno, std::generic_category());
return {};
}
@@ -44,7 +44,7 @@ getFileContents(
if (fileStream.bad())
{
ec = make_error_code(static_cast<std::errc>(errno));
ec.assign(errno, std::generic_category());
return {};
}

View File

@@ -44,7 +44,7 @@ public:
{
// Test with small max
auto const bad = getFileContents(ec, path, 16);
BEAST_EXPECT(ec && ec.value() == static_cast<int>(std::errc::file_too_large));
BEAST_EXPECT(ec && ec == std::errc::file_too_large);
BEAST_EXPECT(bad.empty());
}
}

View File

@@ -475,9 +475,21 @@ SHAMapStoreImp::makeBackendRotating(std::string path)
{
std::filesystem::path const p = get(section, "path");
std::random_device rd;
std::ostringstream oss;
oss << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8) << rd();
newPath = (p / dbPrefix_).string() + "." + oss.str();
constexpr std::size_t maxAttempts = 100;
for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt)
{
std::ostringstream oss;
oss << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8) << rd();
auto const candidate =
std::filesystem::path((p / dbPrefix_).string() + "." + oss.str());
if (!std::filesystem::exists(candidate))
{
newPath = candidate;
break;
}
}
if (newPath.empty())
Throw<std::runtime_error>("Unable to generate a unique rotating backend path");
}
section.set("path", newPath.string());

View File

@@ -10,7 +10,7 @@
#include <xrpl/rdb/DatabaseCon.h>
#include <cstdint>
#include <filesystem> // VFALCO FIX: This include should not be here
#include <filesystem>
#include <optional>
#include <string>
#include <unordered_set>