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
|
#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();
|
mEntries.clear();
|
||||||
mLedger = ledger;
|
mLedger = ledger;
|
||||||
mSet.init(transactionID, ledgerID);
|
mSet.init(transactionID, ledgerID);
|
||||||
|
mParams = params;
|
||||||
mSeq = 0;
|
mSeq = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,20 @@
|
|||||||
DEFINE_INSTANCE(LedgerEntrySetEntry);
|
DEFINE_INSTANCE(LedgerEntrySetEntry);
|
||||||
DEFINE_INSTANCE(LedgerEntrySet);
|
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
|
enum LedgerEntryAction
|
||||||
{
|
{
|
||||||
taaNONE,
|
taaNONE,
|
||||||
@@ -39,6 +53,7 @@ protected:
|
|||||||
Ledger::pointer mLedger;
|
Ledger::pointer mLedger;
|
||||||
std::map<uint256, LedgerEntrySetEntry> mEntries; // cannot be unordered!
|
std::map<uint256, LedgerEntrySetEntry> mEntries; // cannot be unordered!
|
||||||
TransactionMetaSet mSet;
|
TransactionMetaSet mSet;
|
||||||
|
TransactionEngineParams mParams;
|
||||||
int mSeq;
|
int mSeq;
|
||||||
|
|
||||||
LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &e,
|
LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &e,
|
||||||
@@ -56,18 +71,19 @@ protected:
|
|||||||
|
|
||||||
public:
|
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
|
// set functions
|
||||||
LedgerEntrySet duplicate() const; // Make a duplicate of this set
|
LedgerEntrySet duplicate() const; // Make a duplicate of this set
|
||||||
void setTo(const LedgerEntrySet&); // Set this set to have the same contents as another
|
void setTo(const LedgerEntrySet&); // Set this set to have the same contents as another
|
||||||
void swapWith(LedgerEntrySet&); // Swap the contents of two sets
|
void swapWith(LedgerEntrySet&); // Swap the contents of two sets
|
||||||
|
|
||||||
int getSeq() const { return mSeq; }
|
int getSeq() const { return mSeq; }
|
||||||
void bumpSeq() { ++mSeq; }
|
TransactionEngineParams getParams() const { return mParams; }
|
||||||
void init(Ledger::ref ledger, const uint256& transactionID, uint32 ledgerID);
|
void bumpSeq() { ++mSeq; }
|
||||||
|
void init(Ledger::ref ledger, const uint256& transactionID, uint32 ledgerID, TransactionEngineParams params);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
Ledger::pointer& getLedger() { return mLedger; }
|
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: uBookEnd=%s") % uBookEnd);
|
||||||
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uTipIndex=%s") % uTipIndex);
|
cLog(lsTRACE) << boost::str(boost::format("getBookPage: uTipIndex=%s") % uTipIndex);
|
||||||
|
|
||||||
LedgerEntrySet lesActive(lpLedger);
|
LedgerEntrySet lesActive(lpLedger, tapNONE);
|
||||||
|
|
||||||
bool bDone = false;
|
bool bDone = false;
|
||||||
bool bDirectAdvance = true;
|
bool bDirectAdvance = true;
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ bool Pathfinder::bDefaultPath(const STPath& spPath)
|
|||||||
if (pspCurrent)
|
if (pspCurrent)
|
||||||
{
|
{
|
||||||
bool bDefault;
|
bool bDefault;
|
||||||
LedgerEntrySet lesActive(mLedger);
|
LedgerEntrySet lesActive(mLedger, tapNONE);
|
||||||
|
|
||||||
// Expand the current path.
|
// Expand the current path.
|
||||||
pspCurrent->setExpanded(lesActive, spPath, mDstAccountID, mSrcAccountID);
|
pspCurrent->setExpanded(lesActive, spPath, mDstAccountID, mSrcAccountID);
|
||||||
@@ -160,7 +160,7 @@ Pathfinder::Pathfinder(Ledger::ref ledger,
|
|||||||
// Build the default path.
|
// Build the default path.
|
||||||
// Later, reject anything that expands to the default path as the default is sufficient.
|
// 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);
|
psDefault->setExpanded(lesActive, STPath(), mDstAccountID, mSrcAccountID);
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LedgerEntrySet lesActive(mLedger);
|
LedgerEntrySet lesActive(mLedger, tapNONE);
|
||||||
boost::unordered_map<uint160, AccountItems::pointer> aiMap;
|
boost::unordered_map<uint160, AccountItems::pointer> aiMap;
|
||||||
|
|
||||||
SLE::pointer sleSrc = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mSrcAccountID));
|
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;
|
cost = rpcCOST_EXPENSIVE;
|
||||||
Ledger::pointer lSnapShot = boost::make_shared<Ledger>(boost::ref(*lpLedger), false);
|
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.
|
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>";
|
cLog(lsTRACE) << "applyTransaction>";
|
||||||
didApply = false;
|
didApply = false;
|
||||||
assert(mLedger);
|
assert(mLedger);
|
||||||
mNodes.init(mLedger, txn.getTransactionID(), mLedger->getLedgerSeq());
|
mNodes.init(mLedger, txn.getTransactionID(), mLedger->getLedgerSeq(), params);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (1)
|
if (1)
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/unordered_map.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 "Ledger.h"
|
||||||
#include "SerializedTransaction.h"
|
#include "SerializedTransaction.h"
|
||||||
@@ -11,29 +14,12 @@
|
|||||||
#include "TransactionErr.h"
|
#include "TransactionErr.h"
|
||||||
#include "InstanceCounter.h"
|
#include "InstanceCounter.h"
|
||||||
|
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
DEFINE_INSTANCE(TransactionEngine);
|
DEFINE_INSTANCE(TransactionEngine);
|
||||||
|
|
||||||
// A TransactionEngine applies serialized transactions to a ledger
|
// A TransactionEngine applies serialized transactions to a ledger
|
||||||
// It can also, verify signatures, verify fees, and give rejection reasons
|
// 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.
|
// One instance per ledger.
|
||||||
// Only one transaction applied at a time.
|
// Only one transaction applied at a time.
|
||||||
class TransactionEngine : private IS_INSTANCE(TransactionEngine)
|
class TransactionEngine : private IS_INSTANCE(TransactionEngine)
|
||||||
|
|||||||
Reference in New Issue
Block a user