mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Clean up the TransactionEngineParameter flags. Clarify the semantics for
soft failure. Note that the code will not yet invoke a transaction with a retry flag, but the support is there for transcations to handle it.
This commit is contained in:
@@ -799,9 +799,9 @@ void LedgerConsensus::Saccept(boost::shared_ptr<LedgerConsensus> This, SHAMap::p
|
||||
}
|
||||
|
||||
void LedgerConsensus::applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn,
|
||||
const Ledger::pointer& ledger, CanonicalTXSet& failedTransactions, bool final)
|
||||
const Ledger::pointer& ledger, CanonicalTXSet& failedTransactions, bool openLedger)
|
||||
{
|
||||
TransactionEngineParams parms = final ? (tepNO_CHECK_FEE | tepUPDATE_TOTAL | tepMETADATA) : tepNONE;
|
||||
TransactionEngineParams parms = openLedger ? temOPEN_LEDGER : temFINAL;
|
||||
#ifndef TRUST_NETWORK
|
||||
try
|
||||
{
|
||||
@@ -832,9 +832,9 @@ void LedgerConsensus::applyTransaction(TransactionEngine& engine, const Serializ
|
||||
}
|
||||
|
||||
void LedgerConsensus::applyTransactions(const SHAMap::pointer& set, const Ledger::pointer& applyLedger,
|
||||
const Ledger::pointer& checkLedger, CanonicalTXSet& failedTransactions, bool final)
|
||||
const Ledger::pointer& checkLedger, CanonicalTXSet& failedTransactions, bool openLgr)
|
||||
{
|
||||
TransactionEngineParams parms = final ? (tepNO_CHECK_FEE | tepUPDATE_TOTAL) : tepNONE;
|
||||
TransactionEngineParams parms = openLgr ? temOPEN_LEDGER : temFINAL;
|
||||
TransactionEngine engine(applyLedger);
|
||||
|
||||
for (SHAMapItem::pointer item = set->peekFirstItem(); !!item; item = set->peekNextItem(item->getTag()))
|
||||
@@ -848,7 +848,7 @@ void LedgerConsensus::applyTransactions(const SHAMap::pointer& set, const Ledger
|
||||
#endif
|
||||
SerializerIterator sit(item->peekSerializer());
|
||||
SerializedTransaction::pointer txn = boost::make_shared<SerializedTransaction>(boost::ref(sit));
|
||||
applyTransaction(engine, txn, applyLedger, failedTransactions, final);
|
||||
applyTransaction(engine, txn, applyLedger, failedTransactions, openLgr);
|
||||
#ifndef TRUST_NETWORK
|
||||
}
|
||||
catch (...)
|
||||
@@ -906,7 +906,7 @@ void LedgerConsensus::accept(const SHAMap::pointer& set)
|
||||
newLCL->armDirty();
|
||||
|
||||
CanonicalTXSet failedTransactions(set->getHash());
|
||||
applyTransactions(set, newLCL, newLCL, failedTransactions, true);
|
||||
applyTransactions(set, newLCL, newLCL, failedTransactions, false);
|
||||
newLCL->setClosed();
|
||||
|
||||
bool closeTimeCorrect = true;
|
||||
@@ -950,7 +950,7 @@ void LedgerConsensus::accept(const SHAMap::pointer& set)
|
||||
Log(lsINFO) << "Test applying disputed transaction that did not get in";
|
||||
SerializerIterator sit(it.second->peekTransaction());
|
||||
SerializedTransaction::pointer txn = boost::make_shared<SerializedTransaction>(boost::ref(sit));
|
||||
applyTransaction(engine, txn, newOL, failedTransactions, false);
|
||||
applyTransaction(engine, txn, newOL, failedTransactions, true);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -961,7 +961,7 @@ void LedgerConsensus::accept(const SHAMap::pointer& set)
|
||||
|
||||
Log(lsINFO) << "Applying transactions from current ledger";
|
||||
applyTransactions(theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap(), newOL, newLCL,
|
||||
failedTransactions, false);
|
||||
failedTransactions, true);
|
||||
theApp->getMasterLedger().pushLedger(newLCL, newOL);
|
||||
mNewLedgerHash = newLCL->getHash();
|
||||
mState = lcsACCEPTED;
|
||||
|
||||
@@ -128,9 +128,9 @@ protected:
|
||||
void removePosition(LedgerProposal&, bool ours);
|
||||
void sendHaveTxSet(const uint256& set, bool direct);
|
||||
void applyTransactions(const SHAMap::pointer& transactionSet, const Ledger::pointer& targetLedger,
|
||||
const Ledger::pointer& checkLedger, CanonicalTXSet& failedTransactions, bool final);
|
||||
const Ledger::pointer& checkLedger, CanonicalTXSet& failedTransactions, bool openLgr);
|
||||
void applyTransaction(TransactionEngine& engine, const SerializedTransaction::pointer& txn,
|
||||
const Ledger::pointer& targetLedger, CanonicalTXSet& failedTransactions, bool final);
|
||||
const Ledger::pointer& targetLedger, CanonicalTXSet& failedTransactions, bool openLgr);
|
||||
|
||||
// manipulating our own position
|
||||
void statusChange(newcoin::NodeEvent, Ledger& ledger);
|
||||
|
||||
@@ -84,7 +84,7 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans,
|
||||
return trans;
|
||||
}
|
||||
|
||||
TER r = mLedgerMaster->doTransaction(*trans->getSTransaction(), tgtLedger, tepNONE);
|
||||
TER r = mLedgerMaster->doTransaction(*trans->getSTransaction(), tgtLedger, temOPEN_LEDGER);
|
||||
if (r == tefFAILURE) throw Fault(IO_ERROR);
|
||||
|
||||
if (r == terPRE_SEQ)
|
||||
|
||||
@@ -973,7 +973,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn,
|
||||
naSigningPubKey = NewcoinAddress::createAccountPublic(txn.peekSigningPubKey());
|
||||
|
||||
// Consistency: really signed.
|
||||
if ((tesSUCCESS == terResult) && ((params & tepNO_CHECK_SIGN) == 0) && !txn.checkSign(naSigningPubKey))
|
||||
if ((tesSUCCESS == terResult) && ((params & temNO_CHECK_SIGN) == 0) && !txn.checkSign(naSigningPubKey))
|
||||
{
|
||||
Log(lsWARNING) << "applyTransaction: Invalid transaction: bad signature";
|
||||
|
||||
@@ -1032,8 +1032,8 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn,
|
||||
|
||||
STAmount saPaid = txn.getTransactionFee();
|
||||
|
||||
if (tesSUCCESS == terResult && (params & tepNO_CHECK_FEE) == tepNONE)
|
||||
{
|
||||
if (tesSUCCESS == terResult && (params & temOPEN_LEDGER) != temNONE)
|
||||
{ // Applying to open ledger, check fee
|
||||
if (!!saCost)
|
||||
{
|
||||
// XXX DO NOT CHECK ON CONSENSUS PASS
|
||||
@@ -1322,7 +1322,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn,
|
||||
if (!mLedger->addTransaction(txID, s))
|
||||
assert(false);
|
||||
|
||||
if ((params & tepUPDATE_TOTAL) != tepNONE)
|
||||
if ((params & temOPEN_LEDGER) == temNONE)
|
||||
mLedger->destroyCoins(saPaid.getNValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ enum TER // aka TransactionEngineResult
|
||||
|
||||
// 100 .. P Partial success (SR) (ripple transaction with no good paths, pay to non-existent account)
|
||||
// Transaction can be applied, can charge fee, forwarded, but does not achieve optimal result.
|
||||
tepPARITAL = 100,
|
||||
tepPARTIAL = 100,
|
||||
tepPATH_DRY,
|
||||
tepPATH_PARTIAL,
|
||||
};
|
||||
@@ -93,11 +93,11 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman);
|
||||
|
||||
enum TransactionEngineParams
|
||||
{
|
||||
tepNONE = 0,
|
||||
tepNO_CHECK_SIGN = 1, // Signature already checked
|
||||
tepNO_CHECK_FEE = 2, // It was voted into a ledger anyway
|
||||
tepUPDATE_TOTAL = 4, // Update the total coins
|
||||
tepMETADATA = 5, // put metadata in tree, not transaction
|
||||
temNONE = 0x00,
|
||||
temNO_CHECK_SIGN = 0x01, // Signature already checked
|
||||
temOPEN_LEDGER = 0x10, // Transaction is running against an open ledger
|
||||
temRETRY_OK = 0x20, // It was voted into a ledger anyway
|
||||
temFINAL = 0x40, // This may be the transaction's last pass
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user