Cache for immutable LES's.

This commit is contained in:
JoelKatz
2013-05-14 18:36:14 -07:00
parent 423635d2ef
commit 29d86eba55
2 changed files with 10 additions and 6 deletions

View File

@@ -94,7 +94,7 @@ SLE::pointer LedgerEntrySet::entryCache(LedgerEntryType letType, const uint256&
if (!sleEntry) if (!sleEntry)
{ {
assert(action != taaDELETE); assert(action != taaDELETE);
sleEntry = mLedger->getSLE(index); sleEntry = mImmutable ? mLedger->getSLEi(index) : mLedger->getSLE(index);
if (sleEntry) if (sleEntry)
entryCache(sleEntry); entryCache(sleEntry);
} }
@@ -138,7 +138,7 @@ void LedgerEntrySet::entryCache(SLE::ref sle)
void LedgerEntrySet::entryCreate(SLE::ref sle) void LedgerEntrySet::entryCreate(SLE::ref sle)
{ {
assert(mLedger); assert(mLedger && !mImmutable);
assert(sle->isMutable()); assert(sle->isMutable());
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex()); std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
if (it == mEntries.end()) if (it == mEntries.end())
@@ -175,7 +175,7 @@ void LedgerEntrySet::entryCreate(SLE::ref sle)
void LedgerEntrySet::entryModify(SLE::ref sle) void LedgerEntrySet::entryModify(SLE::ref sle)
{ {
assert(sle->isMutable()); assert(sle->isMutable() && !mImmutable);
assert(mLedger); assert(mLedger);
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex()); std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
if (it == mEntries.end()) if (it == mEntries.end())
@@ -209,7 +209,7 @@ void LedgerEntrySet::entryModify(SLE::ref sle)
void LedgerEntrySet::entryDelete(SLE::ref sle) void LedgerEntrySet::entryDelete(SLE::ref sle)
{ {
assert(sle->isMutable()); assert(sle->isMutable() && !mImmutable);
assert(mLedger); assert(mLedger);
std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex()); std::map<uint256, LedgerEntrySetEntry>::iterator it = mEntries.find(sle->getIndex());
if (it == mEntries.end()) if (it == mEntries.end())

View File

@@ -56,6 +56,7 @@ protected:
TransactionMetaSet mSet; TransactionMetaSet mSet;
TransactionEngineParams mParams; TransactionEngineParams mParams;
int mSeq; int mSeq;
bool mImmutable;
LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &e, LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &e,
const TransactionMetaSet& s, int m) : mLedger(ledger), mEntries(e), mSet(s), mParams(tapNONE), mSeq(m) { ; } const TransactionMetaSet& s, int m) : mLedger(ledger), mEntries(e), mSet(s), mParams(tapNONE), mSeq(m) { ; }
@@ -72,11 +73,14 @@ protected:
public: public:
LedgerEntrySet(Ledger::ref ledger, TransactionEngineParams tep) : mLedger(ledger), mParams(tep), mSeq(0) { ; } LedgerEntrySet(Ledger::ref ledger, TransactionEngineParams tep, bool immutable = false) :
mLedger(ledger), mParams(tep), mSeq(0), mImmutable(immutable) { ; }
LedgerEntrySet() : mParams(tapNONE), mSeq(0) { ; } LedgerEntrySet() : mParams(tapNONE), mSeq(0), mImmutable(false) { ; }
// set functions // set functions
void setImmutable() { mImmutable = true; }
bool isImmutable() const { return mImmutable; }
LedgerEntrySet duplicate() const; // Make a duplicate of this set LedgerEntrySet duplicate() const; // Make a duplicate of this set
void setTo(const LedgerEntrySet&); // Set this set to have the same contents as another void setTo(const LedgerEntrySet&); // Set this set to have the same contents as another
void swapWith(LedgerEntrySet&); // Swap the contents of two sets void swapWith(LedgerEntrySet&); // Swap the contents of two sets