diff --git a/src/Ledger.cpp b/src/Ledger.cpp index 00f8864fc..697e0eb1e 100644 --- a/src/Ledger.cpp +++ b/src/Ledger.cpp @@ -317,7 +317,7 @@ bool Ledger::getTransaction(const uint256& txID, Transaction::pointer& txn, Tran txn = Transaction::sharedTransaction(it.getVL(), true); else it.getVL(); // skip transaction - meta = boost::make_shared(mLedgerSeq, it.getVL()); + meta = boost::make_shared(txID, mLedgerSeq, it.getVL()); } else return false; @@ -554,7 +554,7 @@ Json::Value Ledger::getJson(int options) SerializerIterator tsit(sTxn); SerializedTransaction txn(tsit); - TransactionMetaSet meta(mLedgerSeq, sit.getVL()); + TransactionMetaSet meta(item->getTag(), mLedgerSeq, sit.getVL()); Json::Value txJson = txn.getJson(0); txJson["metaData"] = meta.getJson(0); txns.append(txJson); diff --git a/src/LedgerEntrySet.cpp b/src/LedgerEntrySet.cpp index e804f33c2..64321a271 100644 --- a/src/LedgerEntrySet.cpp +++ b/src/LedgerEntrySet.cpp @@ -318,7 +318,8 @@ bool LedgerEntrySet::threadTx(SLE::ref threadTo, Ledger::ref ledger, uint32 prevLgrID; if (!threadTo->thread(mSet.getTxID(), mSet.getLgrSeq(), prevTxID, prevLgrID)) return false; - if (mSet.getAffectedNode(threadTo->getIndex(), TMNModifiedNode, false).thread(prevTxID, prevLgrID)) + if (TransactionMetaSet::thread(mSet.getAffectedNode(threadTo->getIndex(), sfModifiedNode, false), + prevTxID, prevLgrID)) return true; assert(false); return false; @@ -356,7 +357,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) for (std::map::const_iterator it = mEntries.begin(), end = mEntries.end(); it != end; ++it) { - int nType = TMNEndOfMetadata; + SField::ptr type = &sfGeneric; switch (it->second.mAction) { @@ -364,28 +365,28 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) #ifdef META_DEBUG cLog(lsTRACE) << "Modified Node " << it->first; #endif - nType = TMNModifiedNode; + type = &sfModifiedNode; break; case taaDELETE: #ifdef META_DEBUG cLog(lsTRACE) << "Deleted Node " << it->first; #endif - nType = TMNDeletedNode; + type = &sfDeletedNode; break; case taaCREATE: #ifdef META_DEBUG cLog(lsTRACE) << "Created Node " << it->first; #endif - nType = TMNCreatedNode; + type = &sfCreatedNode; break; default: // ignore these break; } - if (nType == TMNEndOfMetadata) + if (type == &sfGeneric) continue; SLE::pointer origNode = mLedger->getSLE(it->first); @@ -394,9 +395,9 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) continue; SLE::pointer curNode = it->second.mEntry; - TransactionMetaNode &metaNode = mSet.getAffectedNode(it->first, nType, true); + STObject &metaNode = mSet.getAffectedNode(it->first, *type, true); - if (nType == TMNDeletedNode) + if (type == &sfDeletedNode) { assert(origNode); threadOwners(origNode, mLedger, newMod); @@ -405,16 +406,16 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) { // node has an amount, covers ripple state nodes STAmount amount = origNode->getFieldAmount(sfAmount); if (amount.isNonZero()) - metaNode.addAmount(TMSPrevBalance, amount); + metaNode.setFieldAmount(sfPreviousBalance, amount); amount = curNode->getFieldAmount(sfAmount); if (amount.isNonZero()) - metaNode.addAmount(TMSFinalBalance, amount); + metaNode.setFieldAmount(sfFinalBalance, amount); if (origNode->getType() == ltRIPPLE_STATE) { - metaNode.addAccount(TMSLowID, + metaNode.setFieldAccount(sfLowID, NewcoinAddress::createAccountID(origNode->getFieldAmount(sfLowLimit).getIssuer())); - metaNode.addAccount(TMSHighID, + metaNode.setFieldAccount(sfHighID, NewcoinAddress::createAccountID(origNode->getFieldAmount(sfHighLimit).getIssuer())); } } @@ -423,44 +424,44 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) { // check for non-zero balances STAmount amount = origNode->getFieldAmount(sfTakerPays); if (amount.isNonZero()) - metaNode.addAmount(TMSFinalTakerPays, amount); + metaNode.setFieldAmount(sfFinalTakerPays, amount); amount = origNode->getFieldAmount(sfTakerGets); if (amount.isNonZero()) - metaNode.addAmount(TMSFinalTakerGets, amount); + metaNode.setFieldAmount(sfFinalTakerGets, amount); } } - if (nType == TMNCreatedNode) // if created, thread to owner(s) + if (type == &sfCreatedNode) // if created, thread to owner(s) { assert(!origNode); threadOwners(curNode, mLedger, newMod); } - if ((nType == TMNCreatedNode) || (nType == TMNModifiedNode)) + if ((type == &sfCreatedNode) || (type == &sfModifiedNode)) { if (curNode->isThreadedType()) // always thread to self threadTx(curNode, mLedger, newMod); } - if (nType == TMNModifiedNode) + if (type == &sfModifiedNode) { assert(origNode); if (origNode->isFieldPresent(sfAmount)) { // node has an amount, covers account root nodes and ripple nodes STAmount amount = origNode->getFieldAmount(sfAmount); if (amount != curNode->getFieldAmount(sfAmount)) - metaNode.addAmount(TMSPrevBalance, amount); + metaNode.setFieldAmount(sfPreviousBalance, amount); } if (origNode->getType() == ltOFFER) { STAmount amount = origNode->getFieldAmount(sfTakerPays); if (amount != curNode->getFieldAmount(sfTakerPays)) - metaNode.addAmount(TMSPrevTakerPays, amount); + metaNode.setFieldAmount(sfPreviousTakerPays, amount); amount = origNode->getFieldAmount(sfTakerGets); if (amount != curNode->getFieldAmount(sfTakerGets)) - metaNode.addAmount(TMSPrevTakerGets, amount); + metaNode.setFieldAmount(sfPreviousTakerGets, amount); } }