mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +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:
@@ -20,6 +20,7 @@
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/protocol/Quality.h>
|
||||
#include <ripple/app/tx/impl/Transactor.h>
|
||||
#include <ripple/ledger/ViewAPI.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/TxFlags.h>
|
||||
@@ -152,18 +153,16 @@ public:
|
||||
// trust line to oneself to be deleted. If no such trust
|
||||
// lines exist now, why not remove this code and simply
|
||||
// return an error?
|
||||
SLE::pointer selDelete (
|
||||
mEngine->view().entryCache (ltRIPPLE_STATE,
|
||||
getRippleStateIndex (
|
||||
mTxnAccountID, uDstAccountID, currency)));
|
||||
SLE::pointer sleDelete = mEngine->view().peek (
|
||||
keylet::line(mTxnAccountID, uDstAccountID, currency));
|
||||
|
||||
if (selDelete)
|
||||
if (sleDelete)
|
||||
{
|
||||
m_journal.warning <<
|
||||
"Clearing redundant line.";
|
||||
|
||||
return mEngine->view ().trustDelete (
|
||||
selDelete, mTxnAccountID, uDstAccountID);
|
||||
return trustDelete (mEngine->view(),
|
||||
sleDelete, mTxnAccountID, uDstAccountID);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -173,8 +172,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
SLE::pointer sleDst (mEngine->view().entryCache (
|
||||
ltACCOUNT_ROOT, getAccountRootIndex (uDstAccountID)));
|
||||
SLE::pointer sleDst =
|
||||
mEngine->view().peek (keylet::account(uDstAccountID));
|
||||
|
||||
if (!sleDst)
|
||||
{
|
||||
@@ -186,8 +185,8 @@ public:
|
||||
STAmount saLimitAllow = saLimitAmount;
|
||||
saLimitAllow.setIssuer (mTxnAccountID);
|
||||
|
||||
SLE::pointer sleRippleState (mEngine->view().entryCache (ltRIPPLE_STATE,
|
||||
getRippleStateIndex (mTxnAccountID, uDstAccountID, currency)));
|
||||
SLE::pointer sleRippleState = mEngine->view().peek (
|
||||
keylet::line(mTxnAccountID, uDstAccountID, currency));
|
||||
|
||||
if (sleRippleState)
|
||||
{
|
||||
@@ -381,7 +380,8 @@ public:
|
||||
{
|
||||
// Delete.
|
||||
|
||||
terResult = mEngine->view ().trustDelete (sleRippleState, uLowAccountID, uHighAccountID);
|
||||
terResult = trustDelete (mEngine->view(),
|
||||
sleRippleState, uLowAccountID, uHighAccountID);
|
||||
}
|
||||
// Reserve is not scaled by load.
|
||||
else if (bReserveIncrease && mPriorBalance < reserveCreate)
|
||||
@@ -395,7 +395,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
mEngine->view().entryModify (sleRippleState);
|
||||
mEngine->view().update (sleRippleState);
|
||||
|
||||
m_journal.trace << "Modify ripple line";
|
||||
}
|
||||
@@ -430,19 +430,19 @@ public:
|
||||
to_string (index);
|
||||
|
||||
// Create a new ripple line.
|
||||
terResult = mEngine->view ().trustCreate (
|
||||
bHigh,
|
||||
mTxnAccountID,
|
||||
uDstAccountID,
|
||||
index,
|
||||
mTxnAccount,
|
||||
bSetAuth,
|
||||
bSetNoRipple && !bClearNoRipple,
|
||||
bSetFreeze && !bClearFreeze,
|
||||
saBalance,
|
||||
saLimitAllow, // Limit for who is being charged.
|
||||
uQualityIn,
|
||||
uQualityOut);
|
||||
terResult = trustCreate (mEngine->view(),
|
||||
bHigh,
|
||||
mTxnAccountID,
|
||||
uDstAccountID,
|
||||
index,
|
||||
mTxnAccount,
|
||||
bSetAuth,
|
||||
bSetNoRipple && !bClearNoRipple,
|
||||
bSetFreeze && !bClearFreeze,
|
||||
saBalance,
|
||||
saLimitAllow, // Limit for who is being charged.
|
||||
uQualityIn,
|
||||
uQualityOut);
|
||||
}
|
||||
|
||||
return terResult;
|
||||
|
||||
Reference in New Issue
Block a user