Support AccountTxnID and LastLedgerSequence.

This commit is contained in:
David Schwartz
2014-01-03 13:01:57 -08:00
committed by JoelKatz
parent fb63aa737a
commit 9486fc416c
8 changed files with 38 additions and 1 deletions

View File

@@ -156,6 +156,24 @@ TER AccountSetTransactor::doApply ()
uFlagsOut &= ~lsfDisableMaster;
}
//
// Track transaction IDs signed by this account in its root
//
if ((uSetFlag == asfAccountTxnID) && (uClearFlag != asfAccountTxnID) && !mTxnAccount->isFieldPresent (sfAccountTxnID))
{
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Set AccountTxnID";
mTxnAccount->makeFieldPresent (sfAccountTxnID);
}
if ((uClearFlag == asfAccountTxnID) && (uSetFlag != asfAccountTxnID) && mTxnAccount->isFieldPresent (sfAccountTxnID))
{
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Clear AccountTxnID";
mTxnAccount->makeFieldAbsent (sfAccountTxnID);
}
//
// EmailHash
//

View File

@@ -170,12 +170,24 @@ TER Transactor::checkSeq ()
return tefPAST_SEQ;
}
// Deprecated: Do not use
if (mTxn.isFieldPresent (sfPreviousTxnID) &&
(mTxnAccount->getFieldH256 (sfPreviousTxnID) != mTxn.getFieldH256 (sfPreviousTxnID)))
return tefWRONG_PRIOR;
if (mTxn.isFieldPresent (sfAccountTxnID) &&
(mTxnAccount->getFieldH256 (sfAccountTxnID) != mTxn.getFieldH256 (sfAccountTxnID)))
return tefWRONG_PRIOR;
if (mTxn.isFieldPresent (sfLastLedgerSequence) &&
(mEngine->getLedger()->getLedgerSeq() > mTxn.getFieldU32 (sfLastLedgerSequence)))
return tefMAX_LEDGER;
mTxnAccount->setFieldU32 (sfSequence, t_seq + 1);
if (mTxnAccount->isFieldPresent (sfAccountTxnID))
mTxnAccount->setFieldH256 (sfAccountTxnID, mTxn.getTransactionID ());
return tesSUCCESS;
}

View File

@@ -26,6 +26,7 @@ LedgerFormats::LedgerFormats ()
<< SOElement (sfOwnerCount, SOE_REQUIRED)
<< SOElement (sfPreviousTxnID, SOE_REQUIRED)
<< SOElement (sfPreviousTxnLgrSeq, SOE_REQUIRED)
<< SOElement (sfAccountTxnID, SOE_OPTIONAL)
<< SOElement (sfRegularKey, SOE_OPTIONAL)
<< SOElement (sfEmailHash, SOE_OPTIONAL)
<< SOElement (sfWalletLocator, SOE_OPTIONAL)

View File

@@ -118,6 +118,7 @@ FIELD (PreviousTxnID, HASH256, 5)
FIELD (LedgerIndex, HASH256, 6)
FIELD (WalletLocator, HASH256, 7)
FIELD (RootIndex, HASH256, 8)
FIELD (AccountTxnID, HASH256, 9)
// 256-bit (uncommon)
FIELD (BookDirectory, HASH256, 16)

View File

@@ -63,6 +63,7 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman)
{ tefPAST_SEQ, "tefPAST_SEQ", "This sequence number has already past." },
{ tefWRONG_PRIOR, "tefWRONG_PRIOR", "This previous transaction does not match." },
{ tefMASTER_DISABLED, "tefMASTER_DISABLED", "Master key is disabled." },
{ tefMAX_LEDGER, "tefMAX_LEDGER", "Ledger sequence too high." },
{ telLOCAL_ERROR, "telLOCAL_ERROR", "Local failure." },
{ telBAD_DOMAIN, "telBAD_DOMAIN", "Domain too long." },

View File

@@ -108,6 +108,7 @@ enum TER // aka TransactionEngineResult
tefPAST_SEQ,
tefWRONG_PRIOR,
tefMASTER_DISABLED,
tefMAX_LEDGER,
// -99 .. -1: R Retry (sequence too high, no funds for txn fee, originating account non-existent)
// Causes:

View File

@@ -55,6 +55,7 @@ const uint32 asfRequireDest = 1;
const uint32 asfRequireAuth = 2;
const uint32 asfDisallowXRP = 3;
const uint32 asfDisableMaster = 4;
const uint32 asfAccountTxnID = 5;
// OfferCreate flags:
const uint32 tfPassive = 0x00010000;

View File

@@ -95,7 +95,9 @@ void TxFormats::addCommonFields (Item& item)
<< SOElement(sfSourceTag, SOE_OPTIONAL)
<< SOElement(sfAccount, SOE_REQUIRED)
<< SOElement(sfSequence, SOE_REQUIRED)
<< SOElement(sfPreviousTxnID, SOE_OPTIONAL)
<< SOElement(sfPreviousTxnID, SOE_OPTIONAL) // Deprecated: Do not use
<< SOElement(sfLastLedgerSequence, SOE_OPTIONAL)
<< SOElement(sfAccountTxnID, SOE_OPTIONAL)
<< SOElement(sfFee, SOE_REQUIRED)
<< SOElement(sfOperationLimit, SOE_OPTIONAL)
<< SOElement(sfSigningPubKey, SOE_REQUIRED)