diff --git a/src/cpp/ripple/LedgerEntrySet.cpp b/src/cpp/ripple/LedgerEntrySet.cpp index e7d361c671..50fea37747 100644 --- a/src/cpp/ripple/LedgerEntrySet.cpp +++ b/src/cpp/ripple/LedgerEntrySet.cpp @@ -394,12 +394,10 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result) continue; SLE::pointer origNode = mLedger->getSLE(it.first); - - if (origNode && (origNode->getType() == ltDIR_NODE)) // No metadata for dir nodes - continue; - SLE::pointer curNode = it.second.mEntry; - mSet.setAffectedNode(it.first, *type); + uint16 nodeType = curNode ? curNode->getFieldU16(sfLedgerEntry) : origNode->getFieldU16(sfLedgerEntry); + + mSet.setAffectedNode(it.first, *type, nodeType); if (type == &sfDeletedNode) { @@ -408,8 +406,8 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result) STObject finals(sfFinalFields); BOOST_FOREACH(const SerializedType& obj, *curNode) - { // search the deleted node for values saved on delete - if (obj.getFName().shouldMetaDel() && !obj.isDefault()) + { // save non-default values + if (!obj.isDefault() && (obj.getFName() != sfLedgerEntryType)) finals.addObject(obj); } if (!finals.empty()) @@ -421,7 +419,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result) STObject mods(sfPreviousFields); BOOST_FOREACH(const SerializedType& obj, *origNode) { // search the original node for values saved on modify - if (obj.getFName().shouldMetaMod() && !obj.isDefault() && !curNode->hasMatchingEntry(obj)) + if (!obj.isDefault() && (obj.getFName() != sfLedgerEntryType) && !curNode->hasMatchingEntry(obj)) mods.addObject(obj); } if (!mods.empty()) @@ -432,6 +430,15 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result) { assert(!origNode); threadOwners(curNode, mLedger, newMod); + + STObject news(sfNewFields); + BOOST_FOREACH(const SerializedType& obj, *curNode) + { // save non-default values + if (!obj.isDefault() && (obj.getFName() != sfLedgerEntryType)) + news.addObject(obj); + } + if (!news.empty()) + mSet.getAffectedNode(it.first, *type).addObject(news); } if ((type == &sfCreatedNode) || (type == &sfModifiedNode)) diff --git a/src/cpp/ripple/SerializeProto.h b/src/cpp/ripple/SerializeProto.h index 59acb547a6..00677319a8 100644 --- a/src/cpp/ripple/SerializeProto.h +++ b/src/cpp/ripple/SerializeProto.h @@ -133,7 +133,8 @@ FIELD(ModifiedNode, OBJECT, 5) FIELD(PreviousFields, OBJECT, 6) FIELD(FinalFields, OBJECT, 7) - FIELD(TemplateEntry, OBJECT, 8) + FIELD(NewFields, OBJECT, 8) + FIELD(TemplateEntry, OBJECT, 9) // array of objects // ARRAY/1 is reserved for end of array diff --git a/src/cpp/ripple/TransactionMeta.cpp b/src/cpp/ripple/TransactionMeta.cpp index 182a25a77c..f7b21bb8de 100644 --- a/src/cpp/ripple/TransactionMeta.cpp +++ b/src/cpp/ripple/TransactionMeta.cpp @@ -31,13 +31,14 @@ bool TransactionMetaSet::isNodeAffected(const uint256& node) const return false; } -void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type) +void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type, uint16 nodeType) { // make sure the node exists and force its type BOOST_FOREACH(STObject& it, mNodes) { if (it.getFieldH256(sfLedgerIndex) == node) { it.setFName(type); + it.setFieldU16(sfLedgerEntryType, nodeType); return; } } @@ -47,6 +48,7 @@ void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type) assert(obj.getFName() == type); obj.setFieldH256(sfLedgerIndex, node); + obj.setFieldU16(sfLedgerEntryType, nodeType); } /* diff --git a/src/cpp/ripple/TransactionMeta.h b/src/cpp/ripple/TransactionMeta.h index 994e325a01..a22058089e 100644 --- a/src/cpp/ripple/TransactionMeta.h +++ b/src/cpp/ripple/TransactionMeta.h @@ -39,7 +39,7 @@ public: uint32 getLgrSeq() { return mLedger; } bool isNodeAffected(const uint256&) const; - void setAffectedNode(const uint256&, SField::ref type); + void setAffectedNode(const uint256&, SField::ref type, uint16 nodeType); STObject& getAffectedNode(const uint256&, SField::ref type); STObject& getAffectedNode(const uint256&); const STObject& peekAffectedNode(const uint256&) const;