diff --git a/src/ripple/app/ledger/impl/LedgerToJson.cpp b/src/ripple/app/ledger/impl/LedgerToJson.cpp index 9cef4e65b56..e29f8e1c11c 100644 --- a/src/ripple/app/ledger/impl/LedgerToJson.cpp +++ b/src/ripple/app/ledger/impl/LedgerToJson.cpp @@ -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)); @@ -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) diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 9da570119f4..d4c4dd306c6 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -2222,16 +2222,17 @@ NetworkOPsImp::pubValidation(std::shared_ptr 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( + 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();) {