mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Set up for ledger diffs to populate the metadata.
Special case for unfunded offers -- need to know how much was taken before deletion
This commit is contained in:
@@ -147,7 +147,7 @@ void LedgerEntrySet::entryModify(SLE::pointer& sle)
|
||||
}
|
||||
}
|
||||
|
||||
void LedgerEntrySet::entryDelete(SLE::pointer& sle)
|
||||
void LedgerEntrySet::entryDelete(SLE::pointer& sle, bool unfunded)
|
||||
{
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
|
||||
if (it == mEntries.end())
|
||||
@@ -166,6 +166,13 @@ void LedgerEntrySet::entryDelete(SLE::pointer& sle)
|
||||
it->second.mSeq = mSeq;
|
||||
it->second.mEntry = sle;
|
||||
it->second.mAction = taaDELETE;
|
||||
if (unfunded)
|
||||
{
|
||||
assert(sle->getType() == ltOFFER); // only offers can be unfunded
|
||||
mSet.deleteUnfunded(sle->getIndex(),
|
||||
sle->getIValueFieldAmount(sfTakerPays),
|
||||
sle->getIValueFieldAmount(sfTakerGets));
|
||||
}
|
||||
break;
|
||||
|
||||
case taaCREATE:
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
LedgerEntryAction hasEntry(const uint256& index) const;
|
||||
void entryCache(SLE::pointer&); // Add this entry to the cache
|
||||
void entryCreate(SLE::pointer&); // This entry will be created
|
||||
void entryDelete(SLE::pointer&); // This entry will be deleted
|
||||
void entryDelete(SLE::pointer&, bool unfunded);
|
||||
void entryModify(SLE::pointer&); // This entry will be modified
|
||||
|
||||
// iterator functions
|
||||
|
||||
@@ -706,7 +706,10 @@ SLE::pointer TransactionEngine::entryCache(LedgerEntryType letType, const uint25
|
||||
{
|
||||
sleEntry = mLedger->getSLE(uIndex);
|
||||
if (sleEntry)
|
||||
{
|
||||
mNodes.entryCache(sleEntry);
|
||||
mOrigNodes.entryCache(sleEntry); // So the metadata code can compare to the original
|
||||
}
|
||||
}
|
||||
else if(action == taaDELETE)
|
||||
assert(false);
|
||||
@@ -727,9 +730,9 @@ SLE::pointer TransactionEngine::entryCreate(LedgerEntryType letType, const uint2
|
||||
}
|
||||
|
||||
|
||||
void TransactionEngine::entryDelete(SLE::pointer sleEntry)
|
||||
void TransactionEngine::entryDelete(SLE::pointer sleEntry, bool unfunded)
|
||||
{
|
||||
mNodes.entryDelete(sleEntry);
|
||||
mNodes.entryDelete(sleEntry, unfunded);
|
||||
}
|
||||
|
||||
void TransactionEngine::entryModify(SLE::pointer sleEntry)
|
||||
|
||||
@@ -186,7 +186,7 @@ protected:
|
||||
|
||||
SLE::pointer entryCreate(LedgerEntryType letType, const uint256& uIndex);
|
||||
SLE::pointer entryCache(LedgerEntryType letType, const uint256& uIndex);
|
||||
void entryDelete(SLE::pointer sleEntry);
|
||||
void entryDelete(SLE::pointer sleEntry, bool unfunded = false);
|
||||
void entryModify(SLE::pointer sleEntry);
|
||||
|
||||
void entryReset();
|
||||
|
||||
@@ -230,3 +230,9 @@ void TransactionMetaSet::swap(TransactionMetaSet& s)
|
||||
assert((mTransactionID == s.mTransactionID) && (mLedger == s.mLedger));
|
||||
mNodes.swap(s.mNodes);
|
||||
}
|
||||
|
||||
bool TransactionMetaSet::deleteUnfunded(const uint256& node, const STAmount& firstBalance, const STAmount &secondBalance)
|
||||
{
|
||||
// WRITEME
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,12 @@ public:
|
||||
|
||||
class TMNEUnfunded : public TransactionMetaNodeEntry
|
||||
{ // node was deleted because it was unfunded
|
||||
protected:
|
||||
STAmount firstAmount, secondAmount; // Amounts left when declared unfunded
|
||||
public:
|
||||
TMNEUnfunded() : TransactionMetaNodeEntry(TMNDeleteUnfunded) { ; }
|
||||
TMNEUnfunded(const STAmount& f, const STAmount& s) :
|
||||
TransactionMetaNodeEntry(TMNDeleteUnfunded), firstAmount(f), secondAmount(s) { ; }
|
||||
virtual void addRaw(Serializer&) const;
|
||||
virtual Json::Value getJson(int) const;
|
||||
virtual int compare(const TransactionMetaNodeEntry&) const;
|
||||
@@ -132,7 +136,7 @@ public:
|
||||
|
||||
void threadNode(const uint256& node, const uint256& previousTransaction, uint32 previousLedger);
|
||||
bool signedBy(const uint256& node, const STAmount& fee);
|
||||
bool deleteUnfunded(const uint256& node);
|
||||
bool deleteUnfunded(const uint256& node, const STAmount& firstBalance, const STAmount& secondBalance);
|
||||
bool adjustBalance(const uint256& node, unsigned flags, const STAmount &amount);
|
||||
bool adjustBalances(const uint256& node, unsigned flags, const STAmount &firstAmt, const STAmount &secondAmt);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user