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:
Vinnie Falco
2015-06-05 07:25:45 -07:00
parent 454d2f8c45
commit babaac9305
45 changed files with 1224 additions and 1129 deletions

View File

@@ -149,8 +149,9 @@ bool PathRequest::isValid (RippleLineCache::ref crCache)
if (bValid)
{
auto asSrc = getApp().getOPs ().getAccountState (
crCache->getLedger(), raSrcAccount);
auto asSrc = getAccountState(
*crCache->getLedger(), raSrcAccount,
getApp().getSLECache());
if (!asSrc)
{
@@ -160,8 +161,8 @@ bool PathRequest::isValid (RippleLineCache::ref crCache)
}
else
{
auto asDst = getApp().getOPs ().getAccountState (
lrLedger, raDstAccount);
auto asDst = getAccountState(*lrLedger,
raDstAccount, getApp().getSLECache());
Json::Value& jvDestCur =
(jvStatus[jss::destination_currencies] = Json::arrayValue);
@@ -187,7 +188,7 @@ bool PathRequest::isValid (RippleLineCache::ref crCache)
else
{
bool const disallowXRP (
asDst->peekSLE ().getFlags() & lsfDisallowXRP);
asDst->sle().getFlags() & lsfDisallowXRP);
auto usDestCurrID = accountDestCurrencies (
raDstAccount, crCache, !disallowXRP);
@@ -196,7 +197,7 @@ bool PathRequest::isValid (RippleLineCache::ref crCache)
jvDestCur.append (to_string (currency));
jvStatus["destination_tag"] =
(asDst->peekSLE ().getFlags () & lsfRequireDestTag)
(asDst->sle().getFlags () & lsfRequireDestTag)
!= 0;
}
}