Skip to content

Commit

Permalink
Move change to API version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronek committed Nov 20, 2023
1 parent c0b9bba commit 4548a30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/ripple/app/ledger/impl/LedgerToJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fillJson(
unsigned apiVersion)
{
json[jss::parent_hash] = to_string(info.parentHash);
json[jss::ledger_index] = (apiVersion > 1)
json[jss::ledger_index] = (apiVersion > 2)
? Json::Value(info.seq)
: Json::Value(std::to_string(info.seq));

Expand Down Expand Up @@ -168,7 +168,7 @@ fillJsonTx(
if (validated)
{
auto const seq = fill.ledger.seq();
txJson[jss::ledger_index] = (fill.context->apiVersion > 1)
txJson[jss::ledger_index] = (fill.context->apiVersion > 2)
? Json::Value(seq)
: Json::Value(std::to_string(seq));
if (fill.closeTime)
Expand Down
21 changes: 11 additions & 10 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2222,16 +2222,17 @@ NetworkOPsImp::pubValidation(std::shared_ptr<STValidation> const& val)

// TODO Replace multiObj with jvObj when API versions 1 & 2 are retired
MultiApiJson multiObj = {{jvObj, jvObj, jvObj}};
constexpr std::size_t indexApi1 = apiVersionSelector(1)();
// TODO also version 2
static_assert(indexApi1 == 0);
auto& jvObjApi1 = multiObj.val[indexApi1];
if (jvObjApi1.isMember(jss::ledger_index))
{
// Cast back to API version 1 type of this field, i.e. string
jvObjApi1[jss::ledger_index] =
std::to_string(jvObjApi1[jss::ledger_index].asUInt());
}
visit<RPC::apiMinimumSupportedVersion, RPC::apiMaximumValidVersion>(
multiObj, //
[](Json::Value& jvTx, unsigned int apiVersion) {
// Type conversion for older API versions to string
if (jvTx.isMember(jss::ledger_index) && apiVersion < 3)
{
jvTx[jss::ledger_index] =
std::to_string(jvTx[jss::ledger_index].asUInt());
}
});

for (auto i = mStreamMaps[sValidations].begin();
i != mStreamMaps[sValidations].end();)
{
Expand Down

0 comments on commit 4548a30

Please sign in to comment.