Compare commits

..

5 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
ae624ab894 Remove unnecessary boost/beast/core/string.hpp includes
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-01-30 17:27:50 +00:00
copilot-swe-agent[bot]
21ac390a37 Fix lambda return type inconsistency in ServerHandler
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-01-30 17:02:18 +00:00
copilot-swe-agent[bot]
86aca89bc4 Fix std::string_view constructor usage in BaseWSPeer
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-01-30 16:28:46 +00:00
copilot-swe-agent[bot]
b26dd49fb6 Replace all boost::beast::string_view with std::string_view
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-01-30 16:26:37 +00:00
copilot-swe-agent[bot]
0969281538 Initial plan 2026-01-30 16:23:54 +00:00
11 changed files with 42 additions and 72 deletions

View File

@@ -87,10 +87,6 @@ The `network_id` field was added in the `server_info` response in version 1.5.0
As of 2025-04-04, version 2.5.0 is in development. You can use a pre-release version by building from source or [using the `nightly` package](https://xrpl.org/docs/infrastructure/installation/install-rippled-on-ubuntu).
### Breaking changes in 2.5.0
- `feature`: The `vetoed` field is now always a boolean. Obsolete amendments now have `"vetoed": true` and a new `"obsolete": true` field, instead of the previous `"vetoed": "Obsolete"` string value. This change improves type safety for API clients.
### Additions and bugfixes in 2.5.0
- `channel_authorize`: If `signing_support` is not enabled in the config, the RPC is disabled.

View File

@@ -11,6 +11,7 @@
#include <cctype>
#include <iterator>
#include <string>
#include <string_view>
#include <vector>
namespace beast {
@@ -179,7 +180,7 @@ split_commas(FwdIt first, FwdIt last)
template <class Result = std::vector<std::string>>
Result
split_commas(boost::beast::string_view const& s)
split_commas(std::string_view const& s)
{
return split_commas(s.begin(), s.end());
}

View File

@@ -1,21 +1,20 @@
#ifndef XRPL_JSON_OUTPUT_H_INCLUDED
#define XRPL_JSON_OUTPUT_H_INCLUDED
#include <boost/beast/core/string.hpp>
#include <functional>
#include <string>
#include <string_view>
namespace Json {
class Value;
using Output = std::function<void(boost::beast::string_view const&)>;
using Output = std::function<void(std::string_view const&)>;
inline Output
stringOutput(std::string& s)
{
return [&](boost::beast::string_view const& b) { s.append(b.data(), b.size()); };
return [&](std::string_view const& b) { s.append(b.data(), b.size()); };
}
/** Writes a minimal representation of a Json value to an Output in O(n) time.

View File

@@ -450,7 +450,6 @@ JSS(node_write_retries); // out: GetCounts
JSS(node_writes_delayed); // out::GetCounts
JSS(nth); // out: RPC server_definitions
JSS(obligations); // out: GatewayBalances
JSS(obsolete); // out: AmendmentTableImpl
JSS(offers); // out: NetworkOPs, AccountOffers, Subscribe
JSS(offer_id); // out: insertNFTokenOfferID
JSS(offline); // in: TransactionSign

View File

@@ -18,6 +18,7 @@
#include <functional>
#include <list>
#include <string_view>
namespace xrpl {
@@ -49,7 +50,7 @@ private:
bool ping_active_ = false;
boost::beast::websocket::ping_data payload_;
error_code ec_;
std::function<void(boost::beast::websocket::frame_type, boost::beast::string_view)> control_callback_;
std::function<void(boost::beast::websocket::frame_type, std::string_view)> control_callback_;
public:
template <class Body, class Headers>
@@ -137,7 +138,7 @@ protected:
on_ping(error_code const& ec);
void
on_ping_pong(boost::beast::websocket::frame_type kind, boost::beast::string_view payload);
on_ping_pong(boost::beast::websocket::frame_type kind, std::string_view payload);
void
on_timer(error_code ec);
@@ -390,11 +391,11 @@ BaseWSPeer<Handler, Impl>::on_ping(error_code const& ec)
template <class Handler, class Impl>
void
BaseWSPeer<Handler, Impl>::on_ping_pong(boost::beast::websocket::frame_type kind, boost::beast::string_view payload)
BaseWSPeer<Handler, Impl>::on_ping_pong(boost::beast::websocket::frame_type kind, std::string_view payload)
{
if (kind == boost::beast::websocket::frame_type::pong)
{
boost::beast::string_view p(payload_.begin());
std::string_view p(payload_.begin(), payload_.size());
if (payload == p)
{
close_on_timer_ = false;

View File

@@ -8,6 +8,7 @@
#include <set>
#include <stack>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -87,14 +88,14 @@ public:
}
void
output(boost::beast::string_view const& bytes)
output(std::string_view const& bytes)
{
markStarted();
output_(bytes);
}
void
stringOutput(boost::beast::string_view const& bytes)
stringOutput(std::string_view const& bytes)
{
markStarted();
std::size_t position = 0, writtenUntil = 0;

View File

@@ -140,17 +140,10 @@ class Feature_test : public beast::unit_test::suite
feature.isMember(jss::enabled) && !feature[jss::enabled].asBool(),
feature[jss::name].asString() + " enabled");
BEAST_EXPECTS(
feature.isMember(jss::vetoed) && feature[jss::vetoed].isBool(),
feature[jss::name].asString() + " vetoed is bool");
BEAST_EXPECTS(
feature[jss::vetoed].asBool() == (expectVeto || expectObsolete),
feature[jss::name].asString() + " vetoed value");
if (expectObsolete)
BEAST_EXPECTS(
feature.isMember(jss::obsolete) && feature[jss::obsolete].asBool() == true,
feature[jss::name].asString() + " obsolete");
else
BEAST_EXPECTS(!feature.isMember(jss::obsolete), feature[jss::name].asString() + " no obsolete");
feature.isMember(jss::vetoed) && feature[jss::vetoed].isBool() == !expectObsolete &&
(!feature[jss::vetoed].isBool() || feature[jss::vetoed].asBool() == expectVeto) &&
(feature[jss::vetoed].isBool() || feature[jss::vetoed].asString() == "Obsolete"),
feature[jss::name].asString() + " vetoed");
BEAST_EXPECTS(
feature.isMember(jss::supported) && feature[jss::supported].asBool(),
feature[jss::name].asString() + " supported");
@@ -249,7 +242,6 @@ class Feature_test : public beast::unit_test::suite
(*it).isMember(jss::supported) && (*it)[jss::supported].asBool() == expectSupported,
(*it)[jss::name].asString() + " supported");
BEAST_EXPECT(!(*it).isMember(jss::vetoed));
BEAST_EXPECT(!(*it).isMember(jss::obsolete));
BEAST_EXPECT(!(*it).isMember(jss::majority));
BEAST_EXPECT(!(*it).isMember(jss::count));
BEAST_EXPECT(!(*it).isMember(jss::validations));
@@ -310,20 +302,11 @@ class Feature_test : public beast::unit_test::suite
if (expectEnabled)
BEAST_EXPECTS(!(*it).isMember(jss::vetoed), (*it)[jss::name].asString() + " vetoed");
else
{
BEAST_EXPECTS(
(*it).isMember(jss::vetoed) && (*it)[jss::vetoed].isBool(),
(*it)[jss::name].asString() + " vetoed is bool");
BEAST_EXPECTS(
(*it)[jss::vetoed].asBool() == (expectVeto || expectObsolete),
(*it)[jss::name].asString() + " vetoed value");
if (expectObsolete)
BEAST_EXPECTS(
(*it).isMember(jss::obsolete) && (*it)[jss::obsolete].asBool() == true,
(*it)[jss::name].asString() + " obsolete");
else
BEAST_EXPECTS(!(*it).isMember(jss::obsolete), (*it)[jss::name].asString() + " no obsolete");
}
(*it).isMember(jss::vetoed) && (*it)[jss::vetoed].isBool() == !expectObsolete &&
(!(*it)[jss::vetoed].isBool() || (*it)[jss::vetoed].asBool() == expectVeto) &&
((*it)[jss::vetoed].isBool() || (*it)[jss::vetoed].asString() == "Obsolete"),
(*it)[jss::name].asString() + " vetoed");
BEAST_EXPECTS(
(*it).isMember(jss::supported) && (*it)[jss::supported].asBool() == expectSupported,
(*it)[jss::name].asString() + " supported");
@@ -386,17 +369,10 @@ class Feature_test : public beast::unit_test::suite
(expectVeto || expectObsolete) ^ feature.isMember(jss::majority),
feature[jss::name].asString() + " majority");
BEAST_EXPECTS(
feature.isMember(jss::vetoed) && feature[jss::vetoed].isBool(),
feature[jss::name].asString() + " vetoed is bool");
BEAST_EXPECTS(
feature[jss::vetoed].asBool() == (expectVeto || expectObsolete),
feature[jss::name].asString() + " vetoed value");
if (expectObsolete)
BEAST_EXPECTS(
feature.isMember(jss::obsolete) && feature[jss::obsolete].asBool() == true,
feature[jss::name].asString() + " obsolete");
else
BEAST_EXPECTS(!feature.isMember(jss::obsolete), feature[jss::name].asString() + " no obsolete");
feature.isMember(jss::vetoed) && feature[jss::vetoed].isBool() == !expectObsolete &&
(!feature[jss::vetoed].isBool() || feature[jss::vetoed].asBool() == expectVeto) &&
(feature[jss::vetoed].isBool() || feature[jss::vetoed].asString() == "Obsolete"),
feature[jss::name].asString() + " vetoed");
BEAST_EXPECTS(feature.isMember(jss::count), feature[jss::name].asString() + " count");
BEAST_EXPECTS(feature.isMember(jss::threshold), feature[jss::name].asString() + " threshold");
BEAST_EXPECTS(feature.isMember(jss::validations), feature[jss::name].asString() + " validations");
@@ -484,8 +460,7 @@ class Feature_test : public beast::unit_test::suite
return;
auto feature = *(jrr.begin());
BEAST_EXPECTS(feature[jss::name] == featureName, "name");
BEAST_EXPECTS(feature[jss::vetoed].isBool() && feature[jss::vetoed].asBool() == true, "vetoed");
BEAST_EXPECTS(feature[jss::obsolete].isBool() && feature[jss::obsolete].asBool() == true, "obsolete");
BEAST_EXPECTS(feature[jss::vetoed].isString() && feature[jss::vetoed].asString() == "Obsolete", "vetoed");
jrr = env.rpc("feature", featureName, "reject")[jss::result];
if (!BEAST_EXPECTS(jrr[jss::status] == jss::success, "status"))
@@ -495,8 +470,7 @@ class Feature_test : public beast::unit_test::suite
return;
feature = *(jrr.begin());
BEAST_EXPECTS(feature[jss::name] == featureName, "name");
BEAST_EXPECTS(feature[jss::vetoed].isBool() && feature[jss::vetoed].asBool() == true, "vetoed");
BEAST_EXPECTS(feature[jss::obsolete].isBool() && feature[jss::obsolete].asBool() == true, "obsolete");
BEAST_EXPECTS(feature[jss::vetoed].isString() && feature[jss::vetoed].asString() == "Obsolete", "vetoed");
jrr = env.rpc("feature", featureName, "accept")[jss::result];
if (!BEAST_EXPECTS(jrr[jss::status] == jss::success, "status"))
@@ -506,8 +480,7 @@ class Feature_test : public beast::unit_test::suite
return;
feature = *(jrr.begin());
BEAST_EXPECTS(feature[jss::name] == featureName, "name");
BEAST_EXPECTS(feature[jss::vetoed].isBool() && feature[jss::vetoed].asBool() == true, "vetoed");
BEAST_EXPECTS(feature[jss::obsolete].isBool() && feature[jss::obsolete].asBool() == true, "obsolete");
BEAST_EXPECTS(feature[jss::vetoed].isString() && feature[jss::vetoed].asString() == "Obsolete", "vetoed");
// anything other than accept or reject is an error
jrr = env.rpc("feature", featureName, "maybe");

View File

@@ -903,10 +903,7 @@ AmendmentTableImpl::injectJson(
if (!fs.enabled && isAdmin)
{
if (fs.vote == AmendmentVote::obsolete)
{
v[jss::vetoed] = true;
v[jss::obsolete] = true;
}
v[jss::vetoed] = "Obsolete";
else
v[jss::vetoed] = fs.vote == AmendmentVote::down;
}

View File

@@ -58,7 +58,7 @@ to_string(ProtocolVersion const& p)
}
std::vector<ProtocolVersion>
parseProtocolVersions(boost::beast::string_view const& value)
parseProtocolVersions(std::string_view const& value)
{
static boost::regex re(
"^" // start of line
@@ -127,7 +127,7 @@ negotiateProtocolVersion(std::vector<ProtocolVersion> const& versions)
}
std::optional<ProtocolVersion>
negotiateProtocolVersion(boost::beast::string_view const& versions)
negotiateProtocolVersion(std::string_view const& versions)
{
auto const them = parseProtocolVersions(versions);

View File

@@ -1,11 +1,10 @@
#ifndef XRPL_OVERLAY_PROTOCOLVERSION_H_INCLUDED
#define XRPL_OVERLAY_PROTOCOLVERSION_H_INCLUDED
#include <boost/beast/core/string.hpp>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
@@ -40,7 +39,7 @@ to_string(ProtocolVersion const& p);
no duplicates and will be sorted in ascending protocol order.
*/
std::vector<ProtocolVersion>
parseProtocolVersions(boost::beast::string_view const& s);
parseProtocolVersions(std::string_view const& s);
/** Given a list of supported protocol versions, choose the one we prefer. */
std::optional<ProtocolVersion>
@@ -48,7 +47,7 @@ negotiateProtocolVersion(std::vector<ProtocolVersion> const& versions);
/** Given a list of supported protocol versions, choose the one we prefer. */
std::optional<ProtocolVersion>
negotiateProtocolVersion(boost::beast::string_view const& versions);
negotiateProtocolVersion(std::string_view const& versions);
/** The list of all the protocol versions we support. */
std::string const&

View File

@@ -34,6 +34,7 @@
#include <algorithm>
#include <memory>
#include <stdexcept>
#include <string_view>
namespace xrpl {
@@ -227,7 +228,7 @@ ServerHandler::onHandoff(
static inline Json::Output
makeOutput(Session& session)
{
return [&](boost::beast::string_view const& b) { session.write(b.data(), b.size()); };
return [&](std::string_view const& b) { session.write(b.data(), b.size()); };
}
static std::map<std::string, std::string>
@@ -511,11 +512,14 @@ ServerHandler::processSession(std::shared_ptr<Session> const& session, std::shar
makeOutput(*session),
coro,
forwardedFor(session->request()),
[&] {
[&]() -> std::string_view {
auto const iter = session->request().find("X-User");
if (iter != session->request().end())
return iter->value();
return boost::beast::string_view{};
{
auto const val = iter->value();
return std::string_view(val.data(), val.size());
}
return std::string_view{};
}());
if (beast::rfc2616::is_keep_alive(session->request()))