diff --git a/src/rpc/handlers/AccountInfo.cpp b/src/rpc/handlers/AccountInfo.cpp index 15781a560..1771e03e3 100644 --- a/src/rpc/handlers/AccountInfo.cpp +++ b/src/rpc/handlers/AccountInfo.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -90,6 +91,17 @@ AccountInfoHandler::process(AccountInfoHandler::Input const& input, Context cons auto const isClawbackEnabled = isEnabled(Amendments::Clawback); auto const isTokenEscrowEnabled = isEnabled(Amendments::TokenEscrow); + Output out{ + .ledgerIndex = lgrInfo.seq, + .ledgerHash = ripple::strHex(lgrInfo.hash), + .accountData = sle, + .isDisallowIncomingEnabled = isDisallowIncomingEnabled, + .isClawbackEnabled = isClawbackEnabled, + .isTokenEscrowEnabled = isTokenEscrowEnabled, + .apiVersion = ctx.apiVersion, + .signerLists = std::nullopt + }; + // Return SignerList(s) if that is requested. if (input.signerLists) { // We put the SignerList in an array because of an anticipated @@ -99,7 +111,6 @@ AccountInfoHandler::process(AccountInfoHandler::Input const& input, Context cons // This code will need to be revisited if in the future we // support multiple SignerLists on one account. auto const signers = sharedPtrBackend_->fetchLedgerObject(signersKey.key, lgrInfo.seq, ctx.yield); - std::vector signerList; if (signers) { ripple::STLedgerEntry const sleSigners{ @@ -109,30 +120,11 @@ AccountInfoHandler::process(AccountInfoHandler::Input const& input, Context cons if (!signersKey.check(sleSigners)) return Error{Status{RippledError::rpcDB_DESERIALIZATION}}; - signerList.push_back(sleSigners); + out.signerLists = std::vector{sleSigners}; } - - return Output( - lgrInfo.seq, - ripple::strHex(lgrInfo.hash), - sle, - isDisallowIncomingEnabled, - isClawbackEnabled, - isTokenEscrowEnabled, - ctx.apiVersion, - signerList - ); } - return Output( - lgrInfo.seq, - ripple::strHex(lgrInfo.hash), - sle, - isDisallowIncomingEnabled, - isClawbackEnabled, - isTokenEscrowEnabled, - ctx.apiVersion - ); + return out; } void diff --git a/src/rpc/handlers/AccountInfo.hpp b/src/rpc/handlers/AccountInfo.hpp index 263516df8..2c2fa05a2 100644 --- a/src/rpc/handlers/AccountInfo.hpp +++ b/src/rpc/handlers/AccountInfo.hpp @@ -66,39 +66,6 @@ public: std::optional> signerLists; // validated should be sent via framework bool validated = true; - - /** - * @brief Construct a new Output object - * - * @param ledgerId The ledger index - * @param ledgerHash The ledger hash - * @param sle The account data - * @param isDisallowIncomingEnabled Whether disallow incoming is enabled - * @param isClawbackEnabled Whether clawback is enabled - * @param isTokenEscrowEnabled Whether token escrow is enabled - * @param version The API version - * @param signerLists The signer lists - */ - Output( - uint32_t ledgerId, - std::string ledgerHash, - ripple::STLedgerEntry sle, - bool isDisallowIncomingEnabled, - bool isClawbackEnabled, - bool isTokenEscrowEnabled, - uint32_t version, - std::optional> signerLists = std::nullopt - ) - : ledgerIndex(ledgerId) - , ledgerHash(std::move(ledgerHash)) - , accountData(std::move(sle)) - , isDisallowIncomingEnabled(isDisallowIncomingEnabled) - , isClawbackEnabled(isClawbackEnabled) - , isTokenEscrowEnabled(isTokenEscrowEnabled) - , apiVersion(version) - , signerLists(std::move(signerLists)) - { - } }; /** diff --git a/src/rpc/handlers/GetAggregatePrice.cpp b/src/rpc/handlers/GetAggregatePrice.cpp index a91ecc849..258ed9032 100644 --- a/src/rpc/handlers/GetAggregatePrice.cpp +++ b/src/rpc/handlers/GetAggregatePrice.cpp @@ -124,7 +124,13 @@ GetAggregatePriceHandler::process(GetAggregatePriceHandler::Input const& input, auto const latestTime = timestampPricesBiMap.left.begin()->first; - Output out(latestTime, ripple::to_string(lgrInfo.hash), lgrInfo.seq); + Output out{ + .time = latestTime, + .trimStats = std::nullopt, + .ledgerHash = ripple::to_string(lgrInfo.hash), + .ledgerIndex = lgrInfo.seq, + .median = "" + }; if (input.timeThreshold) { auto const oldestTime = timestampPricesBiMap.left.rbegin()->first; diff --git a/src/rpc/handlers/GetAggregatePrice.hpp b/src/rpc/handlers/GetAggregatePrice.hpp index fe4c9a121..b66247bfa 100644 --- a/src/rpc/handlers/GetAggregatePrice.hpp +++ b/src/rpc/handlers/GetAggregatePrice.hpp @@ -43,7 +43,6 @@ #include #include #include -#include #include namespace rpc { @@ -59,8 +58,9 @@ public: * @brief A struct to hold the statistics */ struct Stats { - ripple::STAmount avg; - ripple::Number sd; // standard deviation + ripple::STAmount avg{}; // NOLINT(readability-redundant-member-init) + // standard deviation + ripple::Number sd{}; // NOLINT(readability-redundant-member-init) uint32_t size{0}; }; @@ -69,23 +69,12 @@ public: */ struct Output { uint32_t time; - Stats extireStats; + Stats extireStats{}; std::optional trimStats; std::string ledgerHash; uint32_t ledgerIndex; std::string median; bool validated = true; - - /** - * @brief Construct a new Output object - * @param time The time of the latest oracle data - * @param ledgerHash The hash of the ledger - * @param ledgerIndex The index of the ledger - */ - Output(uint32_t time, std::string ledgerHash, uint32_t ledgerIndex) - : time(time), ledgerHash(std::move(ledgerHash)), ledgerIndex(ledgerIndex) - { - } }; /**