mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +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:
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/rpc/impl/GetAccountObjects.h>
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
|
||||
@@ -38,8 +39,9 @@ getAccountObjects (Ledger const& ledger, Account const& account,
|
||||
found = true;
|
||||
}
|
||||
|
||||
auto dir = ledger.getDirNode (dirIndex);
|
||||
if (dir == nullptr)
|
||||
auto dir = fetch(ledger, dirIndex,
|
||||
getApp().getSLECache(), ltDIR_NODE);
|
||||
if (! dir)
|
||||
return false;
|
||||
|
||||
std::uint32_t i = 0;
|
||||
@@ -60,7 +62,8 @@ getAccountObjects (Ledger const& ledger, Account const& account,
|
||||
|
||||
for (; iter != entries.end (); ++iter)
|
||||
{
|
||||
auto const sleNode = ledger.getSLEi (*iter);
|
||||
auto const sleNode = fetch(ledger, *iter,
|
||||
getApp().getSLECache());
|
||||
if (type == ltINVALID || sleNode->getType () == type)
|
||||
{
|
||||
jvObjects.append (sleNode->getJson (0));
|
||||
@@ -84,9 +87,10 @@ getAccountObjects (Ledger const& ledger, Account const& account,
|
||||
if (nodeIndex == 0)
|
||||
return true;
|
||||
|
||||
dirIndex = getDirNodeIndex (rootDirIndex, nodeIndex);
|
||||
dir = ledger.getDirNode (dirIndex);
|
||||
if (dir == nullptr)
|
||||
dirIndex = getDirNodeIndex (rootDirIndex, nodeIndex);
|
||||
dir = fetch(ledger, dirIndex,
|
||||
getApp().getSLECache(), ltDIR_NODE);
|
||||
if (! dir)
|
||||
return true;
|
||||
|
||||
if (i == limit)
|
||||
|
||||
Reference in New Issue
Block a user