mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Refactor Ledger and LedgerEntrySet:
Member functions and free functions on Ledger and LedgerEntrySet are rewritten in terms of new abstract interfaces `BasicView` and `View`, representing the set of non-decomposable primitives necessary to read and write state map items in a ledger, and to overlay a discardable view onto a Ledger that can calculate metadata during transaction processing. const-correctness is enforced through the parameter and return types. The MetaView now supports multi-level stacking: A MetaView can be stacked on top of either a Ledger or another MetaView, up to any number of levels. The getSLEi member function is removed. The CachedView wrapper replaces it, wrapping a View such that any function called with a CachedView will go through the SLECache. * Add BasicView, View, CachedView * Rename LedgerEntrySet to MetaView * Factor out free functions * Consolidate free functions in ViewAPI * Remove unused class members and free functions
This commit is contained in:
@@ -1042,7 +1042,7 @@ void ApplicationImp::startNewLedger ()
|
||||
|
||||
{
|
||||
Ledger::pointer firstLedger = std::make_shared<Ledger> (rootAddress, SYSTEM_CURRENCY_START);
|
||||
assert (firstLedger->exists(getAccountRootIndex(rootAddress.getAccountID())));
|
||||
assert (firstLedger->exists(keylet::account(rootAddress.getAccountID())));
|
||||
// TODO(david): Add any default amendments
|
||||
// TODO(david): Set default fee/reserve
|
||||
firstLedger->getHash(); // updates the hash
|
||||
@@ -1054,7 +1054,7 @@ void ApplicationImp::startNewLedger ()
|
||||
secondLedger->setClosed ();
|
||||
secondLedger->setAccepted ();
|
||||
m_ledgerMaster->pushLedger (secondLedger, std::make_shared<Ledger> (true, std::ref (*secondLedger)));
|
||||
assert (secondLedger->exists(getAccountRootIndex(rootAddress.getAccountID())));
|
||||
assert (secondLedger->exists(keylet::account(rootAddress.getAccountID())));
|
||||
m_networkOPs->setLastCloseTime (secondLedger->getCloseTimeNC ());
|
||||
}
|
||||
}
|
||||
@@ -1310,22 +1310,23 @@ bool ApplicationImp::loadOldLedger (
|
||||
if (replay)
|
||||
{
|
||||
// inject transaction(s) from the replayLedger into our open ledger
|
||||
std::shared_ptr<SHAMap> const& txns = replayLedger->peekTransactionMap();
|
||||
auto const& txns = replayLedger->txMap();
|
||||
|
||||
// Get a mutable snapshot of the open ledger
|
||||
Ledger::pointer cur = getLedgerMaster().getCurrentLedger();
|
||||
cur = std::make_shared <Ledger> (*cur, true);
|
||||
assert (!cur->isImmutable());
|
||||
|
||||
for (auto const& item : *txns)
|
||||
for (auto const& item : txns)
|
||||
{
|
||||
auto const txn =
|
||||
replayLedger->getTransaction(item->getTag());
|
||||
getTransaction(*replayLedger, item->getTag(),
|
||||
getApp().getMasterTransaction());
|
||||
if (m_journal.info) m_journal.info <<
|
||||
txn->getJson(0);
|
||||
Serializer s;
|
||||
txn->getSTransaction()->add(s);
|
||||
if (! cur->addTransaction(item->getTag(), s))
|
||||
if (! addTransaction(*cur, item->getTag(), s))
|
||||
if (m_journal.warning) m_journal.warning <<
|
||||
"Unable to add transaction " << item->getTag();
|
||||
getApp().getHashRouter().setFlag (item->getTag(), SF_SIGGOOD);
|
||||
|
||||
Reference in New Issue
Block a user