mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 20:05:51 +00:00
allow user to specify no peer in doAccountLines (#193)
This commit is contained in:
@@ -221,6 +221,32 @@ getAccount(
|
||||
return Status{Error::rpcINVALID_PARAMS, field.to_string() + "Malformed"};
|
||||
}
|
||||
|
||||
Status
|
||||
getOptionalAccount(
|
||||
boost::json::object const& request,
|
||||
std::optional<ripple::AccountID>& account,
|
||||
boost::string_view const& field)
|
||||
{
|
||||
if (!request.contains(field))
|
||||
{
|
||||
account = {};
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!request.at(field).is_string())
|
||||
return Status{
|
||||
Error::rpcINVALID_PARAMS, field.to_string() + "NotString"};
|
||||
|
||||
if (auto a = accountFromStringStrict(request.at(field).as_string().c_str());
|
||||
a)
|
||||
{
|
||||
account = a.value();
|
||||
return {};
|
||||
}
|
||||
|
||||
return Status{Error::rpcINVALID_PARAMS, field.to_string() + "Malformed"};
|
||||
}
|
||||
|
||||
Status
|
||||
getAccount(boost::json::object const& request, ripple::AccountID& accountId)
|
||||
{
|
||||
|
||||
@@ -238,6 +238,12 @@ getAccount(
|
||||
ripple::AccountID& destAccount,
|
||||
boost::string_view const& field);
|
||||
|
||||
Status
|
||||
getOptionalAccount(
|
||||
boost::json::object const& request,
|
||||
std::optional<ripple::AccountID>& account,
|
||||
boost::string_view const& field);
|
||||
|
||||
Status
|
||||
getTaker(boost::json::object const& request, ripple::AccountID& takerID);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ addLine(
|
||||
auto lineQualityIn = viewLowest ? lowQualityIn : highQualityIn;
|
||||
auto lineQualityOut = viewLowest ? lowQualityOut : highQualityOut;
|
||||
|
||||
if (peerAccount and peerAccount != lineAccountIDPeer)
|
||||
if (peerAccount && peerAccount != lineAccountIDPeer)
|
||||
return;
|
||||
|
||||
if (!viewLowest)
|
||||
@@ -109,8 +109,9 @@ doAccountLines(Context const& context)
|
||||
if (!rawAcct)
|
||||
return Status{Error::rpcACT_NOT_FOUND, "accountNotFound"};
|
||||
|
||||
ripple::AccountID peerAccount;
|
||||
if (auto const status = getAccount(request, peerAccount, JS(peer)); status)
|
||||
std::optional<ripple::AccountID> peerAccount;
|
||||
if (auto const status = getOptionalAccount(request, peerAccount, JS(peer));
|
||||
status)
|
||||
return status;
|
||||
|
||||
std::uint32_t limit;
|
||||
|
||||
Reference in New Issue
Block a user