mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-16 01:35:52 +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"};
|
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
|
Status
|
||||||
getAccount(boost::json::object const& request, ripple::AccountID& accountId)
|
getAccount(boost::json::object const& request, ripple::AccountID& accountId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -238,6 +238,12 @@ getAccount(
|
|||||||
ripple::AccountID& destAccount,
|
ripple::AccountID& destAccount,
|
||||||
boost::string_view const& field);
|
boost::string_view const& field);
|
||||||
|
|
||||||
|
Status
|
||||||
|
getOptionalAccount(
|
||||||
|
boost::json::object const& request,
|
||||||
|
std::optional<ripple::AccountID>& account,
|
||||||
|
boost::string_view const& field);
|
||||||
|
|
||||||
Status
|
Status
|
||||||
getTaker(boost::json::object const& request, ripple::AccountID& takerID);
|
getTaker(boost::json::object const& request, ripple::AccountID& takerID);
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ addLine(
|
|||||||
auto lineQualityIn = viewLowest ? lowQualityIn : highQualityIn;
|
auto lineQualityIn = viewLowest ? lowQualityIn : highQualityIn;
|
||||||
auto lineQualityOut = viewLowest ? lowQualityOut : highQualityOut;
|
auto lineQualityOut = viewLowest ? lowQualityOut : highQualityOut;
|
||||||
|
|
||||||
if (peerAccount and peerAccount != lineAccountIDPeer)
|
if (peerAccount && peerAccount != lineAccountIDPeer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!viewLowest)
|
if (!viewLowest)
|
||||||
@@ -109,8 +109,9 @@ doAccountLines(Context const& context)
|
|||||||
if (!rawAcct)
|
if (!rawAcct)
|
||||||
return Status{Error::rpcACT_NOT_FOUND, "accountNotFound"};
|
return Status{Error::rpcACT_NOT_FOUND, "accountNotFound"};
|
||||||
|
|
||||||
ripple::AccountID peerAccount;
|
std::optional<ripple::AccountID> peerAccount;
|
||||||
if (auto const status = getAccount(request, peerAccount, JS(peer)); status)
|
if (auto const status = getOptionalAccount(request, peerAccount, JS(peer));
|
||||||
|
status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
std::uint32_t limit;
|
std::uint32_t limit;
|
||||||
|
|||||||
Reference in New Issue
Block a user