mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 11:35:53 +00:00
Suppress metadata for unmodified nodes. Add a transaction application sequence number to txn metadat.
This commit is contained in:
@@ -359,7 +359,7 @@ bool LedgerEntrySet::threadOwners(SLE::ref node, Ledger::ref ledger,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
void LedgerEntrySet::calcRawMeta(Serializer& s, TER result, uint32 index)
|
||||||
{ // calculate the raw meta data and return it. This must be called before the set is committed
|
{ // calculate the raw meta data and return it. This must be called before the set is committed
|
||||||
|
|
||||||
// Entries modified only as a result of building the transaction metadata
|
// Entries modified only as a result of building the transaction metadata
|
||||||
@@ -402,6 +402,10 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
|||||||
|
|
||||||
SLE::pointer origNode = mLedger->getSLE(it.first);
|
SLE::pointer origNode = mLedger->getSLE(it.first);
|
||||||
SLE::pointer curNode = it.second.mEntry;
|
SLE::pointer curNode = it.second.mEntry;
|
||||||
|
|
||||||
|
if ((type == &sfCreatedNode) && (*curNode == *origNode))
|
||||||
|
continue;
|
||||||
|
|
||||||
uint16 nodeType = curNode ? curNode->getFieldU16(sfLedgerEntryType) : origNode->getFieldU16(sfLedgerEntryType);
|
uint16 nodeType = curNode ? curNode->getFieldU16(sfLedgerEntryType) : origNode->getFieldU16(sfLedgerEntryType);
|
||||||
|
|
||||||
mSet.setAffectedNode(it.first, *type, nodeType);
|
mSet.setAffectedNode(it.first, *type, nodeType);
|
||||||
@@ -478,7 +482,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result)
|
|||||||
BOOST_FOREACH(u256_sle_pair& it, newMod)
|
BOOST_FOREACH(u256_sle_pair& it, newMod)
|
||||||
entryModify(it.second);
|
entryModify(it.second);
|
||||||
|
|
||||||
mSet.addRaw(s, result);
|
mSet.addRaw(s, result, index);
|
||||||
cLog(lsTRACE) << "Metadata:" << mSet.getJson(0);
|
cLog(lsTRACE) << "Metadata:" << mSet.getJson(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public:
|
|||||||
STAmount accountFunds(const uint160& uAccountID, const STAmount& saDefault);
|
STAmount accountFunds(const uint160& uAccountID, const STAmount& saDefault);
|
||||||
|
|
||||||
Json::Value getJson(int) const;
|
Json::Value getJson(int) const;
|
||||||
void calcRawMeta(Serializer&, TER result);
|
void calcRawMeta(Serializer&, TER result, uint32 index);
|
||||||
|
|
||||||
// iterator functions
|
// iterator functions
|
||||||
typedef std::map<uint256, LedgerEntrySetEntry>::iterator iterator;
|
typedef std::map<uint256, LedgerEntrySetEntry>::iterator iterator;
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
FIELD(OfferSequence, UINT32, 25)
|
FIELD(OfferSequence, UINT32, 25)
|
||||||
FIELD(FirstLedgerSequence, UINT32, 26)
|
FIELD(FirstLedgerSequence, UINT32, 26)
|
||||||
FIELD(LastLedgerSequence, UINT32, 27)
|
FIELD(LastLedgerSequence, UINT32, 27)
|
||||||
|
FIELD(TransactionIndex, UINT32, 28)
|
||||||
|
|
||||||
// 64-bit integers
|
// 64-bit integers
|
||||||
FIELD(IndexNext, UINT64, 1)
|
FIELD(IndexNext, UINT64, 1)
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
|||||||
{
|
{
|
||||||
// Transaction succeeded fully or (retries are not allowed and the transaction succeeded partially).
|
// Transaction succeeded fully or (retries are not allowed and the transaction succeeded partially).
|
||||||
Serializer m;
|
Serializer m;
|
||||||
mNodes.calcRawMeta(m, terResult);
|
mNodes.calcRawMeta(m, terResult, mTxnSeq++);
|
||||||
|
|
||||||
txnWrite();
|
txnWrite();
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
Ledger::pointer mLedger;
|
Ledger::pointer mLedger;
|
||||||
|
int mTxnSeq;
|
||||||
|
|
||||||
uint160 mTxnAccountID;
|
uint160 mTxnAccountID;
|
||||||
SLE::pointer mTxnAccount;
|
SLE::pointer mTxnAccount;
|
||||||
@@ -65,8 +66,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<TransactionEngine> pointer;
|
typedef boost::shared_ptr<TransactionEngine> pointer;
|
||||||
|
|
||||||
TransactionEngine() { ; }
|
TransactionEngine() : mTxnSeq(0) { ; }
|
||||||
TransactionEngine(Ledger::ref ledger) : mLedger(ledger) { assert(mLedger); }
|
TransactionEngine(Ledger::ref ledger) : mLedger(ledger), mTxnSeq(0) { assert(mLedger); }
|
||||||
|
|
||||||
LedgerEntrySet& getNodes() { return mNodes; }
|
LedgerEntrySet& getNodes() { return mNodes; }
|
||||||
Ledger::pointer getLedger() { return mLedger; }
|
Ledger::pointer getLedger() { return mLedger; }
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ TransactionMetaSet::TransactionMetaSet(const uint256& txid, uint32 ledger, const
|
|||||||
throw std::runtime_error("bad metadata");
|
throw std::runtime_error("bad metadata");
|
||||||
|
|
||||||
mResult = obj->getFieldU8(sfTransactionResult);
|
mResult = obj->getFieldU8(sfTransactionResult);
|
||||||
|
mIndex = obj->getFieldU32(sfTransactionIndex);
|
||||||
mNodes = * dynamic_cast<STArray*>(&obj->getField(sfAffectedNodes));
|
mNodes = * dynamic_cast<STArray*>(&obj->getField(sfAffectedNodes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,13 +156,15 @@ STObject TransactionMetaSet::getAsObject() const
|
|||||||
STObject metaData(sfTransactionMetaData);
|
STObject metaData(sfTransactionMetaData);
|
||||||
assert(mResult != 255);
|
assert(mResult != 255);
|
||||||
metaData.setFieldU8(sfTransactionResult, mResult);
|
metaData.setFieldU8(sfTransactionResult, mResult);
|
||||||
|
metaData.setFieldU32(sfTransactionIndex, mIndex);
|
||||||
metaData.addObject(mNodes);
|
metaData.addObject(mNodes);
|
||||||
return metaData;
|
return metaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionMetaSet::addRaw(Serializer& s, TER result)
|
void TransactionMetaSet::addRaw(Serializer& s, TER result, uint32 index)
|
||||||
{
|
{
|
||||||
mResult = static_cast<int>(result);
|
mResult = static_cast<int>(result);
|
||||||
|
mIndex = index;
|
||||||
assert((mResult == 0) || ((mResult > 100) && (mResult <= 255)));
|
assert((mResult == 0) || ((mResult > 100) && (mResult <= 255)));
|
||||||
|
|
||||||
mNodes.sort(compare);
|
mNodes.sort(compare);
|
||||||
|
|||||||
@@ -23,13 +23,15 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
uint256 mTransactionID;
|
uint256 mTransactionID;
|
||||||
uint32 mLedger;
|
uint32 mLedger;
|
||||||
|
uint32 mIndex;
|
||||||
int mResult;
|
int mResult;
|
||||||
|
|
||||||
STArray mNodes;
|
STArray mNodes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransactionMetaSet() : mLedger(0), mResult(255) { ; }
|
TransactionMetaSet() : mLedger(0), mIndex(static_cast<uint32>(-1)), mResult(255) { ; }
|
||||||
TransactionMetaSet(const uint256& txID, uint32 ledger) : mTransactionID(txID), mLedger(ledger), mResult(255) { ; }
|
TransactionMetaSet(const uint256& txID, uint32 ledger, uint32 index) :
|
||||||
|
mTransactionID(txID), mLedger(ledger), mIndex(static_cast<uint32>(-1)), mResult(255) { ; }
|
||||||
TransactionMetaSet(const uint256& txID, uint32 ledger, const std::vector<unsigned char>&);
|
TransactionMetaSet(const uint256& txID, uint32 ledger, const std::vector<unsigned char>&);
|
||||||
|
|
||||||
void init(const uint256& transactionID, uint32 ledger);
|
void init(const uint256& transactionID, uint32 ledger);
|
||||||
@@ -40,6 +42,7 @@ public:
|
|||||||
uint32 getLgrSeq() { return mLedger; }
|
uint32 getLgrSeq() { return mLedger; }
|
||||||
int getResult() const { return mResult; }
|
int getResult() const { return mResult; }
|
||||||
TER getResultTER() const { return static_cast<TER>(mResult); }
|
TER getResultTER() const { return static_cast<TER>(mResult); }
|
||||||
|
uint32 getIndex() const { return mIndex; }
|
||||||
|
|
||||||
bool isNodeAffected(const uint256&) const;
|
bool isNodeAffected(const uint256&) const;
|
||||||
void setAffectedNode(const uint256&, SField::ref type, uint16 nodeType);
|
void setAffectedNode(const uint256&, SField::ref type, uint16 nodeType);
|
||||||
@@ -50,7 +53,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
Json::Value getJson(int p) const { return getAsObject().getJson(p); }
|
Json::Value getJson(int p) const { return getAsObject().getJson(p); }
|
||||||
void addRaw(Serializer&, TER);
|
void addRaw(Serializer&, TER, uint32 index);
|
||||||
|
|
||||||
STObject getAsObject() const;
|
STObject getAsObject() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user