Remove Account field from AccountRootNode.

This commit is contained in:
Arthur Britto
2012-08-14 15:50:35 -07:00
parent 07f5bf2612
commit 5ddbf968bf
3 changed files with 28 additions and 34 deletions

View File

@@ -7,7 +7,6 @@ LedgerEntryFormat LedgerFormats[]=
{ {
{ "AccountRoot", ltACCOUNT_ROOT, { { "AccountRoot", ltACCOUNT_ROOT, {
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 }, { S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
{ S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
{ S_FIELD(LastReceive), STI_UINT32, SOE_REQUIRED, 0 }, { S_FIELD(LastReceive), STI_UINT32, SOE_REQUIRED, 0 },

View File

@@ -818,7 +818,7 @@ SLE::pointer TransactionEngine::entryCache(LedgerEntryType letType, const uint25
mOrigNodes.entryCache(sleEntry); // So the metadata code can compare to the original mOrigNodes.entryCache(sleEntry); // So the metadata code can compare to the original
} }
} }
else if(action == taaDELETE) else if (action == taaDELETE)
assert(false); assert(false);
} }
@@ -3165,7 +3165,7 @@ PathState::PathState(
STAmount saSendMax, STAmount saSendMax,
bool bPartialPayment bool bPartialPayment
) )
: mIndex(iIndex), uQuality(0), bDirty(true) : mIndex(iIndex), uQuality(0)
{ {
lesEntries = lesSource.duplicate(); lesEntries = lesSource.duplicate();
@@ -3228,11 +3228,12 @@ void TransactionEngine::pathNext(PathState::pointer pspCur, int iPaths)
unsigned int uLast = pspCur->vpnNodes.size() - 1; unsigned int uLast = pspCur->vpnNodes.size() - 1;
pspCur->lesEntries = mNodes.duplicate(); // Checkpoint state?
if (!calcNode(uLast, pspCur, iPaths == 1)) if (!calcNode(uLast, pspCur, iPaths == 1))
{ {
// Mark path as inactive. // Mark path as inactive.
pspCur->uQuality = 0; pspCur->uQuality = 0;
pspCur->bDirty = false;
} }
} }
@@ -3309,7 +3310,6 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
// Create the account. // Create the account.
sleDst = entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID)); sleDst = entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
sleDst->setIFieldAccount(sfAccount, uDstAccountID);
sleDst->setIFieldU32(sfSequence, 1); sleDst->setIFieldU32(sfSequence, 1);
} }
else else
@@ -3343,9 +3343,12 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
// Ripple payment // Ripple payment
// //
#if 0
// Disabled to make sure full ripple code is correct.
// Try direct ripple first. // Try direct ripple first.
if (!bNoRippleDirect && mTxnAccountID != uDstAccountID && uSrcCurrency == uDstCurrency) if (!bNoRippleDirect && mTxnAccountID != uDstAccountID && uSrcCurrency == uDstCurrency)
{ {
// XXX Does not handle quality.
SLE::pointer sleRippleState = entryCache(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uDstCurrency)); SLE::pointer sleRippleState = entryCache(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uDstCurrency));
if (sleRippleState) if (sleRippleState)
@@ -3425,16 +3428,18 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
return terSUCCESS; return terSUCCESS;
} }
} }
#endif
STPathSet spsPaths = txn.getITFieldPathSet(sfPaths); STPathSet spsPaths = txn.getITFieldPathSet(sfPaths);
if (!spsPaths.isEmpty()) if (!bNoRippleDirect && spsPaths.isEmpty())
{ {
Log(lsINFO) << "doPayment: Invalid transaction: No paths."; Log(lsINFO) << "doPayment: Invalid transaction: No paths and direct ripple not allowed.";
return tenRIPPLE_EMPTY; return tenRIPPLE_EMPTY;
} }
else if (spsPaths.getPathCount() > RIPPLE_PATHS_MAX)
if (spsPaths.getPathCount() > RIPPLE_PATHS_MAX)
{ {
return tenBAD_PATH_COUNT; return tenBAD_PATH_COUNT;
} }
@@ -3442,6 +3447,21 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
// Incrementally search paths. // Incrementally search paths.
std::vector<PathState::pointer> vpsPaths; std::vector<PathState::pointer> vpsPaths;
if (!bNoRippleDirect)
{
// Direct path.
vpsPaths.push_back(PathState::createPathState(
vpsPaths.size(),
mNodes,
STPath(),
uDstAccountID,
mTxnAccountID,
saDstAmount,
saMaxAmount,
bPartialPayment
));
}
BOOST_FOREACH(const STPath& spPath, spsPaths) BOOST_FOREACH(const STPath& spPath, spsPaths)
{ {
vpsPaths.push_back(PathState::createPathState( vpsPaths.push_back(PathState::createPathState(
@@ -3468,14 +3488,7 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
// Find the best path. // Find the best path.
BOOST_FOREACH(PathState::pointer pspCur, vpsPaths) BOOST_FOREACH(PathState::pointer pspCur, vpsPaths)
{ {
if (pspCur->bDirty) pathNext(pspCur, vpsPaths.size()); // Compute increment
{
pspCur->bDirty = false;
pspCur->lesEntries = mNodes.duplicate();
// XXX Compute increment
pathNext(pspCur, vpsPaths.size());
}
if (!pspBest || (pspCur->uQuality && PathState::lessPriority(pspBest, pspCur))) if (!pspBest || (pspCur->uQuality && PathState::lessPriority(pspBest, pspCur)))
pspBest = pspCur; pspBest = pspCur;
@@ -3490,22 +3503,6 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
// Install changes for path. // Install changes for path.
mNodes.swapWith(pspBest->lesEntries); mNodes.swapWith(pspBest->lesEntries);
// Mark that path as dirty.
pspBest->bDirty = true;
// Mark as dirty any other path that intersected.
BOOST_FOREACH(PathState::pointer& pspOther, vpsPaths)
{
// Look for intersection of best and the others.
// - Will forget the intersection applied.
// - Anything left will not interfere with it.
// - Will remember the non-intersection non-applied for future consideration.
if (!pspOther->bDirty
&& pspOther->uQuality
&& LedgerEntrySet::intersect(pspBest->lesEntries, pspOther->lesEntries))
pspOther->bDirty = true;
}
// Figure out if done. // Figure out if done.
if (tenUNKNOWN == terResult && saPaid == saWanted) if (tenUNKNOWN == terResult && saPaid == saWanted)
{ {
@@ -3581,7 +3578,6 @@ TransactionEngineResult TransactionEngine::doWalletAdd(const SerializedTransacti
// Create the account. // Create the account.
sleDst = entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID)); sleDst = entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
sleDst->setIFieldAccount(sfAccount, uDstAccountID);
sleDst->setIFieldU32(sfSequence, 1); sleDst->setIFieldU32(sfSequence, 1);
sleDst->setIFieldAmount(sfBalance, saAmount); sleDst->setIFieldAmount(sfBalance, saAmount);
sleDst->setIFieldAccount(sfAuthorizedKey, uAuthKeyID); sleDst->setIFieldAccount(sfAuthorizedKey, uAuthKeyID);

View File

@@ -139,7 +139,6 @@ public:
STAmount saInAct; // Amount spent by sender (calc output) STAmount saInAct; // Amount spent by sender (calc output)
STAmount saOutReq; // Amount to send (calc input) STAmount saOutReq; // Amount to send (calc input)
STAmount saOutAct; // Amount actually sent (calc output). STAmount saOutAct; // Amount actually sent (calc output).
bool bDirty; // Path not computed.
PathState( PathState(
int iIndex, int iIndex,