Skip to content

Commit

Permalink
[FOLD] Replace sequence with documentID
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Dec 20, 2023
1 parent 68461d4 commit 70e61ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/ripple/rpc/handlers/GetAggregatePrice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ doGetAggregatePrice(RPC::JsonContext& context)
if (!params.isMember(jss::quote_asset))
return RPC::missing_field_error(jss::quote_asset);

auto getField = [&](Json::StaticString const& field,
// Lambda to get `trim` and `time_threshold` fields. If the field
// is not included in the input then a default value is returned.
auto getField = [&params](
Json::StaticString const& field,
unsigned int def =
0) -> std::variant<std::uint32_t, error_code_i> {
if (params.isMember(field))
Expand Down Expand Up @@ -210,13 +213,13 @@ doGetAggregatePrice(RPC::JsonContext& context)
RPC::inject_error(rpcORACLE_MALFORMED, result);
return result;
}
auto const sequence = oracle[jss::oracle_document_id].isConvertibleTo(
Json::ValueType::uintValue)
auto const documentID = oracle[jss::oracle_document_id].isConvertibleTo(
Json::ValueType::uintValue)
? std::make_optional(oracle[jss::oracle_document_id].asUInt())
: std::nullopt;
auto const account =
parseBase58<AccountID>(oracle[jss::account].asString());
if (!account || account->isZero() || !sequence)
if (!account || account->isZero() || !documentID)
{
RPC::inject_error(rpcINVALID_PARAMS, result);
return result;
Expand All @@ -227,7 +230,7 @@ doGetAggregatePrice(RPC::JsonContext& context)
if (!ledger)
return result;

auto const sle = ledger->read(keylet::oracle(*account, *sequence));
auto const sle = ledger->read(keylet::oracle(*account, *documentID));
iteratePriceData(context, sle, [&](STObject const& node) {
auto const& series = node.getFieldArray(sfPriceDataSeries);
// find the token pair entry with the price
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/rpc/handlers/LedgerEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ doLedgerEntry(RPC::JsonContext& context)
{
uNodeIndex = beast::zero;
auto const& oracle = context.params[jss::oracle];
auto const sequence =
auto const documentID =
oracle[jss::oracle_document_id].isConvertibleTo(
Json::ValueType::uintValue)
? std::make_optional(
Expand All @@ -631,10 +631,10 @@ doLedgerEntry(RPC::JsonContext& context)
parseBase58<AccountID>(oracle[jss::account].asString());
if (!account || account->isZero())
jvResult[jss::error] = "malformedAddress";
else if (!sequence)
else if (!documentID)
jvResult[jss::error] = "malformedSequence";
else
uNodeIndex = keylet::oracle(*account, *sequence).key;
uNodeIndex = keylet::oracle(*account, *documentID).key;
}
}
else
Expand Down

0 comments on commit 70e61ba

Please sign in to comment.