diff --git a/src/ripple/app/ledger/LedgerToJson.h b/src/ripple/app/ledger/LedgerToJson.h index f658583885f..78947ca91d1 100644 --- a/src/ripple/app/ledger/LedgerToJson.h +++ b/src/ripple/app/ledger/LedgerToJson.h @@ -21,8 +21,10 @@ #define RIPPLE_APP_LEDGER_LEDGERTOJSON_H_INCLUDED #include +#include #include #include +#include #include #include #include @@ -41,6 +43,8 @@ struct LedgerFill LedgerEntryType t = ltANY) : ledger(l), options(o), txQueue(std::move(q)), type(t), context(ctx) { + if (context) + closeTime = context->ledgerMaster.getCloseTimeBySeq(ledger.seq()); } enum Options { @@ -58,6 +62,7 @@ struct LedgerFill std::vector txQueue; LedgerEntryType type; RPC::Context* context; + std::optional closeTime; }; /** Given a Ledger and options, fill a Json::Object or Json::Value with a diff --git a/src/ripple/app/ledger/impl/LedgerToJson.cpp b/src/ripple/app/ledger/impl/LedgerToJson.cpp index 6b3f42d62df..c6cfb7cb5a8 100644 --- a/src/ripple/app/ledger/impl/LedgerToJson.cpp +++ b/src/ripple/app/ledger/impl/LedgerToJson.cpp @@ -162,10 +162,9 @@ fillJsonTx( { txJson[jss::ledger_index] = to_string(fill.ledger.seq()); txJson[jss::ledger_hash] = to_string(fill.ledger.info().hash); - if (auto close_time = - fill.context->ledgerMaster.getCloseTimeBySeq( - fill.ledger.seq())) - txJson[jss::close_time_iso] = to_string_iso(*close_time); + if (fill.closeTime) + txJson[jss::close_time_iso] = + to_string_iso(*fill.closeTime); } } else