mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 07:25:51 +00:00
Cache the JSON of an ALTransaction.
This commit is contained in:
@@ -14,17 +14,21 @@ ALTransaction::ALTransaction(uint32 seq, SerializerIterator& sit)
|
||||
mMeta = boost::make_shared<TransactionMetaSet>(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)
|
||||
|
||||
@@ -14,6 +14,9 @@ protected:
|
||||
TER mResult;
|
||||
std::vector<RippleAddress> mAffected;
|
||||
std::vector<unsigned char> 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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user