diff --git a/src/cpp/ripple/AcceptedLedger.cpp b/src/cpp/ripple/AcceptedLedger.cpp index 0043d332d5..6226c3ebcb 100644 --- a/src/cpp/ripple/AcceptedLedger.cpp +++ b/src/cpp/ripple/AcceptedLedger.cpp @@ -14,17 +14,21 @@ ALTransaction::ALTransaction(uint32 seq, SerializerIterator& sit) mMeta = boost::make_shared(mTxn->getTransactionID(), seq, mRawMeta); mAffected = mMeta->getAffectedAccounts(); mResult = mMeta->getResultTER(); + buildJson(); } ALTransaction::ALTransaction(SerializedTransaction::ref txn, TransactionMetaSet::ref met) : mTxn(txn), mMeta(met), mAffected(met->getAffectedAccounts()) { mResult = mMeta->getResultTER(); + buildJson(); } ALTransaction::ALTransaction(SerializedTransaction::ref txn, TER result) : mTxn(txn), mResult(result), mAffected(txn->getMentionedAccounts()) -{ ; } +{ + buildJson(); +} std::string ALTransaction::getEscMeta() const { @@ -32,16 +36,16 @@ std::string ALTransaction::getEscMeta() const return sqlEscape(mRawMeta); } -Json::Value ALTransaction::getJson(int j) const +void ALTransaction::buildJson() { - Json::Value ret(Json::objectValue); - ret["transaction"] = mTxn->getJson(j); + mJson = Json::objectValue; + mJson["transaction"] = mTxn->getJson(0); if (mMeta) { - ret["meta"] = mMeta->getJson(j); - ret["raw_meta"] = strHex(mRawMeta); + mJson["meta"] = mMeta->getJson(0); + mJson["raw_meta"] = strHex(mRawMeta); } - ret["result"] = transHuman(mResult); + mJson["result"] = transHuman(mResult); if (!mAffected.empty()) { @@ -50,10 +54,8 @@ Json::Value ALTransaction::getJson(int j) const { affected.append(ra.humanAccountID()); } - ret["affected"] = affected; + mJson["affected"] = affected; } - - return ret; } AcceptedLedger::AcceptedLedger(Ledger::ref ledger) : mLedger(ledger) diff --git a/src/cpp/ripple/AcceptedLedger.h b/src/cpp/ripple/AcceptedLedger.h index 4b6297e559..dcc662b959 100644 --- a/src/cpp/ripple/AcceptedLedger.h +++ b/src/cpp/ripple/AcceptedLedger.h @@ -14,6 +14,9 @@ protected: TER mResult; std::vector mAffected; std::vector mRawMeta; + Json::Value mJson; + + void buildJson(); public: @@ -32,7 +35,7 @@ public: bool isApplied() const { return !!mMeta; } int getIndex() const { return mMeta ? mMeta->getIndex() : 0; } std::string getEscMeta() const; - Json::Value getJson(int) const; + Json::Value getJson() const { return mJson; } }; class AcceptedLedger diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 8b3e8aa98c..4ad0042228 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -1375,7 +1375,7 @@ void NetworkOPs::pubProposedTransaction(Ledger::ref lpCurrent, SerializedTransac } } ALTransaction alt(stTxn, terResult); - cLog(lsTRACE) << "pubProposed: " << alt.getJson(0); + cLog(lsTRACE) << "pubProposed: " << alt.getJson(); pubAccountTransaction(lpCurrent, ALTransaction(stTxn, terResult), false); } @@ -1429,7 +1429,7 @@ void NetworkOPs::pubLedger(Ledger::ref accepted) { BOOST_FOREACH(const AcceptedLedger::value_type& vt, alpAccepted->getMap()) { - cLog(lsTRACE) << "pubAccepted: " << vt.second.getJson(0); + cLog(lsTRACE) << "pubAccepted: " << vt.second.getJson(); pubValidatedTransaction(lpAccepted, vt.second); } }