mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 05:55:51 +00:00
Make the transaction application parameters accessible from the LES.
This commit is contained in:
@@ -16,11 +16,13 @@ DECLARE_INSTANCE(LedgerEntrySet)
|
||||
|
||||
#define DIR_NODE_MAX 32
|
||||
|
||||
void LedgerEntrySet::init(Ledger::ref ledger, const uint256& transactionID, uint32 ledgerID)
|
||||
void LedgerEntrySet::init(Ledger::ref ledger, const uint256& transactionID,
|
||||
uint32 ledgerID, TransactionEngineParams params)
|
||||
{
|
||||
mEntries.clear();
|
||||
mLedger = ledger;
|
||||
mSet.init(transactionID, ledgerID);
|
||||
mParams = params;
|
||||
mSeq = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,20 @@
|
||||
DEFINE_INSTANCE(LedgerEntrySetEntry);
|
||||
DEFINE_INSTANCE(LedgerEntrySet);
|
||||
|
||||
enum TransactionEngineParams
|
||||
{
|
||||
tapNONE = 0x00,
|
||||
|
||||
tapNO_CHECK_SIGN = 0x01, // Signature already checked
|
||||
|
||||
tapOPEN_LEDGER = 0x10, // Transaction is running against an open ledger
|
||||
// true = failures are not forwarded, check transaction fee
|
||||
// false = debit ledger for consumed funds
|
||||
|
||||
tapRETRY = 0x20, // This is not the transaction's last pass
|
||||
// Transaction can be retried, soft failures allowed
|
||||
};
|
||||
|
||||
enum LedgerEntryAction
|
||||
{
|
||||
taaNONE,
|
||||
@@ -39,6 +53,7 @@ protected:
|
||||
Ledger::pointer mLedger;
|
||||
std::map<uint256, LedgerEntrySetEntry> mEntries; // cannot be unordered!
|
||||
TransactionMetaSet mSet;
|
||||
TransactionEngineParams mParams;
|
||||
int mSeq;
|
||||
|
||||
LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &e,
|
||||
@@ -56,18 +71,19 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
LedgerEntrySet(Ledger::ref ledger) : mLedger(ledger), mSeq(0) { ; }
|
||||
LedgerEntrySet(Ledger::ref ledger, TransactionEngineParams tep) : mLedger(ledger), mParams(tep), mSeq(0) { ; }
|
||||
|
||||
LedgerEntrySet() : mSeq(0) { ; }
|
||||
LedgerEntrySet() : mParams(tapNONE), mSeq(0) { ; }
|
||||
|
||||
// set functions
|
||||
LedgerEntrySet duplicate() const; // Make a duplicate of this set
|
||||
void setTo(const LedgerEntrySet&); // Set this set to have the same contents as another
|
||||
void swapWith(LedgerEntrySet&); // Swap the contents of two sets
|
||||
|
||||
int getSeq() const { return mSeq; }
|
||||
void bumpSeq() { ++mSeq; }
|
||||
void init(Ledger::ref ledger, const uint256& transactionID, uint32 ledgerID);
|
||||
int getSeq() const { return mSeq; }
|
||||
TransactionEngineParams getParams() const { return mParams; }
|
||||
void bumpSeq() { ++mSeq; }
|
||||
void init(Ledger::ref ledger, const uint256& transactionID, uint32 ledgerID, TransactionEngineParams params);
|
||||
void clear();
|
||||
|
||||
Ledger::pointer& getLedger() { return mLedger; }
|
||||
|
||||
@@ -1780,7 +1780,7 @@ void NetworkOPs::getBookPage(Ledger::pointer lpLedger, const uint160& uTakerPays
|
||||
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uBookEnd=%s") % uBookEnd);
|
||||
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uTipIndex=%s") % uTipIndex);
|
||||
|
||||
LedgerEntrySet lesActive(lpLedger);
|
||||
LedgerEntrySet lesActive(lpLedger, tapNONE);
|
||||
|
||||
bool bDone = false;
|
||||
bool bDirectAdvance = true;
|
||||
|
||||
@@ -117,7 +117,7 @@ bool Pathfinder::bDefaultPath(const STPath& spPath)
|
||||
if (pspCurrent)
|
||||
{
|
||||
bool bDefault;
|
||||
LedgerEntrySet lesActive(mLedger);
|
||||
LedgerEntrySet lesActive(mLedger, tapNONE);
|
||||
|
||||
// Expand the current path.
|
||||
pspCurrent->setExpanded(lesActive, spPath, mDstAccountID, mSrcAccountID);
|
||||
@@ -160,7 +160,7 @@ Pathfinder::Pathfinder(Ledger::ref ledger,
|
||||
// Build the default path.
|
||||
// Later, reject anything that expands to the default path as the default is sufficient.
|
||||
|
||||
LedgerEntrySet lesActive(mLedger);
|
||||
LedgerEntrySet lesActive(mLedger, tapNONE);
|
||||
|
||||
psDefault->setExpanded(lesActive, STPath(), mDstAccountID, mSrcAccountID);
|
||||
|
||||
@@ -212,7 +212,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
return false;
|
||||
}
|
||||
|
||||
LedgerEntrySet lesActive(mLedger);
|
||||
LedgerEntrySet lesActive(mLedger, tapNONE);
|
||||
boost::unordered_map<uint160, AccountItems::pointer> aiMap;
|
||||
|
||||
SLE::pointer sleSrc = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mSrcAccountID));
|
||||
|
||||
@@ -1235,7 +1235,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost)
|
||||
|
||||
cost = rpcCOST_EXPENSIVE;
|
||||
Ledger::pointer lSnapShot = boost::make_shared<Ledger>(boost::ref(*lpLedger), false);
|
||||
LedgerEntrySet lesSnapshot(lSnapShot);
|
||||
LedgerEntrySet lesSnapshot(lSnapShot, tapNONE);
|
||||
|
||||
ScopedUnlock su(theApp->getMasterLock()); // As long as we have a locked copy of the ledger, we can unlock.
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
||||
cLog(lsTRACE) << "applyTransaction>";
|
||||
didApply = false;
|
||||
assert(mLedger);
|
||||
mNodes.init(mLedger, txn.getTransactionID(), mLedger->getLedgerSeq());
|
||||
mNodes.init(mLedger, txn.getTransactionID(), mLedger->getLedgerSeq(), params);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (1)
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "Ledger.h"
|
||||
#include "SerializedTransaction.h"
|
||||
@@ -11,29 +14,12 @@
|
||||
#include "TransactionErr.h"
|
||||
#include "InstanceCounter.h"
|
||||
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
DEFINE_INSTANCE(TransactionEngine);
|
||||
|
||||
// A TransactionEngine applies serialized transactions to a ledger
|
||||
// It can also, verify signatures, verify fees, and give rejection reasons
|
||||
|
||||
enum TransactionEngineParams
|
||||
{
|
||||
tapNONE = 0x00,
|
||||
|
||||
tapNO_CHECK_SIGN = 0x01, // Signature already checked
|
||||
|
||||
tapOPEN_LEDGER = 0x10, // Transaction is running against an open ledger
|
||||
// true = failures are not forwarded, check transaction fee
|
||||
// false = debit ledger for consumed funds
|
||||
|
||||
tapRETRY = 0x20, // This is not the transaction's last pass
|
||||
// Transaction can be retried, soft failures allowed
|
||||
};
|
||||
|
||||
// One instance per ledger.
|
||||
// Only one transaction applied at a time.
|
||||
class TransactionEngine : private IS_INSTANCE(TransactionEngine)
|
||||
|
||||
Reference in New Issue
Block a user