Include ledger entry type in metadata. Include more new/changed/final field

values in transactions metadata.
This commit is contained in:
JoelKatz
2012-11-12 13:40:02 -08:00
parent e399be47c4
commit 4fe3f7c7e0
4 changed files with 21 additions and 11 deletions

View File

@@ -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))

View File

@@ -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

View File

@@ -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);
}
/*

View File

@@ -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;