mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 07:25:51 +00:00
Include ledger entry type in metadata. Include more new/changed/final field
values in transactions metadata.
This commit is contained in:
@@ -394,12 +394,10 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
SLE::pointer origNode = mLedger->getSLE(it.first);
|
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;
|
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)
|
if (type == &sfDeletedNode)
|
||||||
{
|
{
|
||||||
@@ -408,8 +406,8 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
|||||||
|
|
||||||
STObject finals(sfFinalFields);
|
STObject finals(sfFinalFields);
|
||||||
BOOST_FOREACH(const SerializedType& obj, *curNode)
|
BOOST_FOREACH(const SerializedType& obj, *curNode)
|
||||||
{ // search the deleted node for values saved on delete
|
{ // save non-default values
|
||||||
if (obj.getFName().shouldMetaDel() && !obj.isDefault())
|
if (!obj.isDefault() && (obj.getFName() != sfLedgerEntryType))
|
||||||
finals.addObject(obj);
|
finals.addObject(obj);
|
||||||
}
|
}
|
||||||
if (!finals.empty())
|
if (!finals.empty())
|
||||||
@@ -421,7 +419,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
|||||||
STObject mods(sfPreviousFields);
|
STObject mods(sfPreviousFields);
|
||||||
BOOST_FOREACH(const SerializedType& obj, *origNode)
|
BOOST_FOREACH(const SerializedType& obj, *origNode)
|
||||||
{ // search the original node for values saved on modify
|
{ // 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);
|
mods.addObject(obj);
|
||||||
}
|
}
|
||||||
if (!mods.empty())
|
if (!mods.empty())
|
||||||
@@ -432,6 +430,15 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
|||||||
{
|
{
|
||||||
assert(!origNode);
|
assert(!origNode);
|
||||||
threadOwners(curNode, mLedger, newMod);
|
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))
|
if ((type == &sfCreatedNode) || (type == &sfModifiedNode))
|
||||||
|
|||||||
@@ -133,7 +133,8 @@
|
|||||||
FIELD(ModifiedNode, OBJECT, 5)
|
FIELD(ModifiedNode, OBJECT, 5)
|
||||||
FIELD(PreviousFields, OBJECT, 6)
|
FIELD(PreviousFields, OBJECT, 6)
|
||||||
FIELD(FinalFields, OBJECT, 7)
|
FIELD(FinalFields, OBJECT, 7)
|
||||||
FIELD(TemplateEntry, OBJECT, 8)
|
FIELD(NewFields, OBJECT, 8)
|
||||||
|
FIELD(TemplateEntry, OBJECT, 9)
|
||||||
|
|
||||||
// array of objects
|
// array of objects
|
||||||
// ARRAY/1 is reserved for end of array
|
// ARRAY/1 is reserved for end of array
|
||||||
|
|||||||
@@ -31,13 +31,14 @@ bool TransactionMetaSet::isNodeAffected(const uint256& node) const
|
|||||||
return false;
|
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
|
{ // make sure the node exists and force its type
|
||||||
BOOST_FOREACH(STObject& it, mNodes)
|
BOOST_FOREACH(STObject& it, mNodes)
|
||||||
{
|
{
|
||||||
if (it.getFieldH256(sfLedgerIndex) == node)
|
if (it.getFieldH256(sfLedgerIndex) == node)
|
||||||
{
|
{
|
||||||
it.setFName(type);
|
it.setFName(type);
|
||||||
|
it.setFieldU16(sfLedgerEntryType, nodeType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +48,7 @@ void TransactionMetaSet::setAffectedNode(const uint256& node, SField::ref type)
|
|||||||
|
|
||||||
assert(obj.getFName() == type);
|
assert(obj.getFName() == type);
|
||||||
obj.setFieldH256(sfLedgerIndex, node);
|
obj.setFieldH256(sfLedgerIndex, node);
|
||||||
|
obj.setFieldU16(sfLedgerEntryType, nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
uint32 getLgrSeq() { return mLedger; }
|
uint32 getLgrSeq() { return mLedger; }
|
||||||
|
|
||||||
bool isNodeAffected(const uint256&) const;
|
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&, SField::ref type);
|
||||||
STObject& getAffectedNode(const uint256&);
|
STObject& getAffectedNode(const uint256&);
|
||||||
const STObject& peekAffectedNode(const uint256&) const;
|
const STObject& peekAffectedNode(const uint256&) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user