mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Refactor Ledger and support classes:
This performs a deep refactor on the Ledger class and its supporting classes, in preparation for the move to shared_ptr<SLE const> in places where the SLE is immutable and we are currently using shared_ptr<SLE>. Member functions are converted to free functions, the SLECache is an explicit parameter, one line convenience functions are removed to streamline the interface. Some callers are changed to use <SLE const> instead of <SLE> SLECache: * Moved to its own header file RippleState: * Remove unused functions * Store the SLE as const * Simplify callers AccountState: * Remove unused members * Simplify existing members Ledger: * Replace writeBack with insert and update * Remove unused functions * Remove LedgerStateParams * Move getLastFullLedger to Application * add entryCacheI, exists, fetch, erase * Use boost::optional where it makes sense * Make member functions free functions Free functions: * fetch: cache-aware SLE retrieval * forEachItem, forEachItemAfter * (various)
This commit is contained in:
@@ -36,6 +36,9 @@ void TransactionEngine::txnWrite ()
|
||||
// Write back the account states
|
||||
for (auto& it : mNodes)
|
||||
{
|
||||
// VFALCO TODO rvalue move the mEntry, make
|
||||
// sure the mNodes is not used after
|
||||
// this function is called.
|
||||
SLE::ref sleEntry = it.second.mEntry;
|
||||
|
||||
switch (it.second.mAction)
|
||||
@@ -49,11 +52,10 @@ void TransactionEngine::txnWrite ()
|
||||
|
||||
case taaCREATE:
|
||||
{
|
||||
// VFALCO Is this logging necessary anymore?
|
||||
WriteLog (lsDEBUG, TransactionEngine) <<
|
||||
"applyTransaction: taaCREATE: " << sleEntry->getText ();
|
||||
|
||||
if (mLedger->writeBack (lepCREATE, sleEntry) & lepERROR)
|
||||
assert (false);
|
||||
mLedger->insert(*sleEntry);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -61,9 +63,7 @@ void TransactionEngine::txnWrite ()
|
||||
{
|
||||
WriteLog (lsDEBUG, TransactionEngine) <<
|
||||
"applyTransaction: taaMODIFY: " << sleEntry->getText ();
|
||||
|
||||
if (mLedger->writeBack (lepNONE, sleEntry) & lepERROR)
|
||||
assert (false);
|
||||
mLedger->replace(*sleEntry);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -71,9 +71,7 @@ void TransactionEngine::txnWrite ()
|
||||
{
|
||||
WriteLog (lsDEBUG, TransactionEngine) <<
|
||||
"applyTransaction: taaDELETE: " << sleEntry->getText ();
|
||||
|
||||
if (!mLedger->peekAccountStateMap ()->delItem (it.first))
|
||||
assert (false);
|
||||
mLedger->erase(it.first);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user