Make sure we don't use an invalid LES. (Adds asserts.)

This commit is contained in:
JoelKatz
2013-04-13 20:25:06 -07:00
parent 8bf3f4f2e3
commit b7484e9264
2 changed files with 8 additions and 0 deletions

View File

@@ -78,6 +78,8 @@ public:
LedgerEntrySet duplicate() const; // Make a duplicate of this set
void setTo(const LedgerEntrySet&); // Set this set to have the same contents as another
void swapWith(LedgerEntrySet&); // Swap the contents of two sets
void invalidate() { mLedger.reset(); }
bool isValid() const { return !!mLedger; }
int getSeq() const { return mSeq; }
TransactionEngineParams getParams() const { return mParams; }

View File

@@ -2649,6 +2649,7 @@ TER RippleCalc::rippleCalc(
const bool bOpenLedger
)
{
assert(lesActive.isValid());
RippleCalc rc(lesActive, bOpenLedger);
cLog(lsTRACE) << boost::str(boost::format("rippleCalc> saMaxAmountReq=%s saDstAmountReq=%s")
@@ -2807,7 +2808,10 @@ int iPass = 0;
% pspCur->saInPass.getFullText()
% pspCur->saOutPass.getFullText());
assert(lesActive.isValid());
lesActive.swapWith(pspCur->lesEntries); // For the path, save ledger state.
lesActive.invalidate();
iBest = pspCur->getIndex();
}
}
@@ -2842,7 +2846,9 @@ int iPass = 0;
vuUnfundedBecame.insert(vuUnfundedBecame.end(), pspBest->vUnfundedBecame.begin(), pspBest->vUnfundedBecame.end());
// Record best pass' LedgerEntrySet to build off of and potentially return.
assert(pspBest->lesEntries.isValid());
lesActive.swapWith(pspBest->lesEntries);
pspBest->lesEntries.invalidate();
saMaxAmountAct += pspBest->saInPass;
saDstAmountAct += pspBest->saOutPass;