mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Beging merging transaction metadata code with ledger entry set code.
This commit is contained in:
@@ -2,20 +2,35 @@
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
void LedgerEntrySet::init(const uint256& transactionID, uint32 ledgerID)
|
||||
{
|
||||
mEntries.clear();
|
||||
mSet.init(transactionID, ledgerID);
|
||||
mSeq = 0;
|
||||
}
|
||||
|
||||
void LedgerEntrySet::clear()
|
||||
{
|
||||
mEntries.clear();
|
||||
mSet.clear();
|
||||
}
|
||||
|
||||
LedgerEntrySet LedgerEntrySet::duplicate()
|
||||
{
|
||||
return LedgerEntrySet(mEntries, mSeq + 1);
|
||||
return LedgerEntrySet(mEntries, mSet, mSeq + 1);
|
||||
}
|
||||
|
||||
void LedgerEntrySet::setTo(LedgerEntrySet& e)
|
||||
{
|
||||
mEntries = e.mEntries;
|
||||
mSet = e.mSet;
|
||||
mSeq = e.mSeq;
|
||||
}
|
||||
|
||||
void LedgerEntrySet::swapWith(LedgerEntrySet& e)
|
||||
{
|
||||
std::swap(mSeq, e.mSeq);
|
||||
mSet.swap(e.mSet);
|
||||
mEntries.swap(e.mEntries);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
#include "SerializedLedger.h"
|
||||
#include "TransactionMeta.h"
|
||||
|
||||
enum LedgerEntryAction
|
||||
{
|
||||
@@ -30,9 +31,11 @@ class LedgerEntrySet
|
||||
{
|
||||
protected:
|
||||
boost::unordered_map<uint256, LedgerEntrySetEntry> mEntries;
|
||||
TransactionMetaSet mSet;
|
||||
int mSeq;
|
||||
|
||||
LedgerEntrySet(const boost::unordered_map<uint256, LedgerEntrySetEntry> &e, int m) : mEntries(e), mSeq(m) { ; }
|
||||
LedgerEntrySet(const boost::unordered_map<uint256, LedgerEntrySetEntry> &e, TransactionMetaSet& s, int m) :
|
||||
mEntries(e), mSet(s), mSeq(m) { ; }
|
||||
|
||||
public:
|
||||
LedgerEntrySet() : mSeq(0) { ; }
|
||||
@@ -44,7 +47,8 @@ public:
|
||||
|
||||
int getSeq() const { return mSeq; }
|
||||
void bumpSeq() { ++mSeq; }
|
||||
void clear() { mEntries.empty(); mSeq = 0; }
|
||||
void init(const uint256& transactionID, uint32 ledgerID);
|
||||
void clear();
|
||||
|
||||
// basic entry functions
|
||||
SLE::pointer getEntry(const uint256& index, LedgerEntryAction&);
|
||||
|
||||
@@ -796,7 +796,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
||||
Log(lsTRACE) << "applyTransaction>";
|
||||
assert(mLedger);
|
||||
mLedgerParentCloseTime = mLedger->getParentCloseTimeNC();
|
||||
mNodes.clear();
|
||||
mNodes.init(txn.getTransactionID(), mLedger->getLedgerSeq());
|
||||
|
||||
#ifdef DEBUG
|
||||
if (1)
|
||||
|
||||
@@ -217,3 +217,16 @@ const TransactionMetaNode& TransactionMetaSet::peekAffectedNode(const uint256& n
|
||||
return *it;
|
||||
throw std::runtime_error("Affected node not found");
|
||||
}
|
||||
|
||||
void TransactionMetaSet::init(const uint256& id, uint32 ledger)
|
||||
{
|
||||
mTransactionID = id;
|
||||
mLedger = ledger;
|
||||
mNodes.clear();
|
||||
}
|
||||
|
||||
void TransactionMetaSet::swap(TransactionMetaSet& s)
|
||||
{
|
||||
assert((mTransactionID == s.mTransactionID) && (mLedger == s.mLedger));
|
||||
mNodes.swap(s.mNodes);
|
||||
}
|
||||
|
||||
@@ -115,10 +115,14 @@ protected:
|
||||
std::set<TransactionMetaNode> mNodes;
|
||||
|
||||
public:
|
||||
TransactionMetaSet(const uint256& txID, uint32 ledger) : mTransactionID(txID), mLedger(ledger)
|
||||
{ ; }
|
||||
TransactionMetaSet() : mLedger(0) { ; }
|
||||
TransactionMetaSet(const uint256& txID, uint32 ledger) : mTransactionID(txID), mLedger(ledger) { ; }
|
||||
TransactionMetaSet(uint32 ledger, const std::vector<unsigned char>&);
|
||||
|
||||
void init(const uint256& transactionID, uint32 ledger);
|
||||
void clear() { mNodes.clear(); }
|
||||
void swap(TransactionMetaSet&);
|
||||
|
||||
bool isNodeAffected(const uint256&) const;
|
||||
TransactionMetaNode getAffectedNode(const uint256&);
|
||||
const TransactionMetaNode& peekAffectedNode(const uint256&) const;
|
||||
|
||||
Reference in New Issue
Block a user