diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 7f6f3cf22..b6d61484b 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -1223,6 +1223,7 @@ false false + true true @@ -1295,43 +1296,55 @@ true true - + true true true true - + true true true true - + true true true true - + true true true true - + true true true true - + true true true true - + + true + true + true + true + + + true + true + true + true + + true true true @@ -1343,6 +1356,12 @@ true true + + true + true + true + true + true true @@ -1373,30 +1392,12 @@ true true - - true - true - true - true - - - true - true - true - true - true true true true - - true - true - true - true - true true @@ -2540,22 +2541,22 @@ - - - - - - - + + + + + + + + + + - - - diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 8902a946a..eb8063f42 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -316,6 +316,9 @@ {0ff855ac-5038-4b16-a324-ba85d782c0e2} + + {dcb7c75c-4f1d-486c-8079-52dc43644ae6} + @@ -747,51 +750,6 @@ [2] Old Ripple\ripple_app\consensus - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - [2] Old Ripple\ripple_app\main @@ -849,12 +807,6 @@ [2] Old Ripple\ripple_app\misc - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - [0] Libraries\protobuf @@ -1488,6 +1440,60 @@ [1] Ripple\peerfinder\impl + + [2] Old Ripple\ripple_app + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + @@ -1973,48 +1979,6 @@ [2] Old Ripple\ripple_app\consensus - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - [2] Old Ripple\ripple_app\main @@ -2063,27 +2027,18 @@ [1] Ripple\ripple_data\protocol - - [1] Ripple\ripple_net\basics - [1] Ripple\ripple_net\basics [1] Ripple\ripple_net\basics - - [1] Ripple\ripple_net\basics - [1] Ripple\ripple_net\basics [1] Ripple\ripple_net\basics - - [1] Ripple\ripple_net\basics\impl - [1] Ripple\ripple_net\basics @@ -2120,12 +2075,6 @@ [2] Old Ripple\ripple_app\misc - - [2] Old Ripple\ripple_app\tx - - - [2] Old Ripple\ripple_app\tx - [2] Old Ripple\ripple_app\misc @@ -3051,6 +3000,54 @@ [1] Ripple\peerfinder\impl + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\tx + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + + + [2] Old Ripple\ripple_app\transactors + diff --git a/SConstruct b/SConstruct index 686350f4d..57904fdf7 100644 --- a/SConstruct +++ b/SConstruct @@ -207,6 +207,7 @@ COMPILED_FILES.extend([ 'src/ripple_app/ripple_app_pt6.cpp', 'src/ripple_app/ripple_app_pt7.cpp', 'src/ripple_app/ripple_app_pt8.cpp', + 'src/ripple_app/ripple_app_pt9.cpp', 'src/ripple_basics/ripple_basics.cpp', 'src/ripple_core/ripple_core.cpp', 'src/ripple_data/ripple_data.cpp', diff --git a/src/ripple_app/ripple_app.h b/src/ripple_app/ripple_app.h index e8b9652cd..5485116c7 100644 --- a/src/ripple_app/ripple_app.h +++ b/src/ripple_app/ripple_app.h @@ -126,15 +126,11 @@ namespace ripple { #include "main/Application.h" namespace ripple { #include "ledger/OrderBookDB.h" -#include "tx/Transactor.h" -#include "tx/ChangeTransactor.h" #include "tx/TransactionAcquire.h" #include "consensus/DisputedTx.h" #include "consensus/LedgerConsensus.h" #include "ledger/LedgerTiming.h" #include "misc/Offer.h" -#include "tx/OfferCancelTransactor.h" -#include "tx/OfferCreateTransactor.h" #include "paths/RippleLineCache.h" #include "paths/PathRequest.h" #include "paths/PathRequests.h" @@ -143,12 +139,7 @@ namespace ripple { #include "paths/PathState.h" #include "paths/RippleCalc.h" #include "paths/Pathfinder.h" -#include "tx/PaymentTransactor.h" -#include "tx/RegularKeySetTransactor.h" #include "paths/RippleState.h" -#include "tx/AccountSetTransactor.h" -#include "tx/TrustSetTransactor.h" -#include "tx/WalletAddTransactor.h" // VFALCO NOTE These contracts files are bunk #include "contracts/ScriptData.h" #include "contracts/Contract.h" diff --git a/src/ripple_app/ripple_app_pt2.cpp b/src/ripple_app/ripple_app_pt2.cpp index a8c4ca6ff..32975ef18 100644 --- a/src/ripple_app/ripple_app_pt2.cpp +++ b/src/ripple_app/ripple_app_pt2.cpp @@ -31,12 +31,10 @@ namespace ripple { #include "shamap/SHAMapMissingNode.cpp" #include "misc/AccountItem.cpp" -#include "tx/AccountSetTransactor.cpp" #include "misc/CanonicalTXSet.cpp" #include "ledger/LedgerProposal.cpp" #include "main/LoadManager.cpp" #include "misc/NicknameState.cpp" -#include "tx/OfferCancelTransactor.cpp" #include "ledger/OrderBookDB.cpp" #include "data/Database.cpp" diff --git a/src/ripple_app/ripple_app_pt3.cpp b/src/ripple_app/ripple_app_pt3.cpp index 0e401bb6e..857ffee63 100644 --- a/src/ripple_app/ripple_app_pt3.cpp +++ b/src/ripple_app/ripple_app_pt3.cpp @@ -30,7 +30,6 @@ namespace ripple #include "shamap/SHAMapTreeNode.cpp" #include "misc/AccountItems.cpp" #include "misc/AccountState.cpp" -#include "tx/ChangeTransactor.cpp" #include "contracts/Contract.cpp" #include "contracts/Operation.cpp" #include "contracts/ScriptData.cpp" diff --git a/src/ripple_app/ripple_app_pt4.cpp b/src/ripple_app/ripple_app_pt4.cpp index da4ab0451..b141e9738 100644 --- a/src/ripple_app/ripple_app_pt4.cpp +++ b/src/ripple_app/ripple_app_pt4.cpp @@ -27,8 +27,9 @@ #include // for UniqueNodeList.cpp -namespace ripple -{ +#include "transactors/Transactor.h" + +namespace ripple { #include "paths/RippleState.cpp" @@ -36,14 +37,10 @@ namespace ripple #include "ledger/InboundLedger.cpp" -#include "tx/PaymentTransactor.cpp" -#include "tx/RegularKeySetTransactor.cpp" #include "tx/TransactionCheck.cpp" #include "tx/TransactionMaster.cpp" -#include "tx/TrustSetTransactor.cpp" #include "tx/Transaction.cpp" #include "tx/TransactionEngine.cpp" #include "tx/TransactionMeta.cpp" -#include "tx/Transactor.cpp" } diff --git a/src/ripple_app/ripple_app_pt5.cpp b/src/ripple_app/ripple_app_pt5.cpp index 7e2099acf..004e00268 100644 --- a/src/ripple_app/ripple_app_pt5.cpp +++ b/src/ripple_app/ripple_app_pt5.cpp @@ -39,7 +39,5 @@ namespace ripple { #include "ledger/AcceptedLedgerTx.cpp" #include "main/LocalCredentials.cpp" #include "misc/Validations.cpp" -#include "tx/OfferCreateTransactor.cpp" -#include "tx/WalletAddTransactor.cpp" #include "misc/FeeVote.cpp" } diff --git a/src/ripple_app/ripple_app_pt9.cpp b/src/ripple_app/ripple_app_pt9.cpp new file mode 100644 index 000000000..849dbc86f --- /dev/null +++ b/src/ripple_app/ripple_app_pt9.cpp @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012, 2013 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#include "BeastConfig.h" + +#include "ripple_app.h" + +#include "transactors/Transactor.cpp" +#include "transactors/ChangeTransactor.cpp" +#include "transactors/OfferCancelTransactor.cpp" +#include "transactors/OfferCreateTransactor.cpp" +#include "transactors/PaymentTransactor.cpp" +#include "transactors/RegularKeySetTransactor.cpp" +#include "transactors/AccountSetTransactor.cpp" +#include "transactors/WalletAddTransactor.cpp" +#include "transactors/TrustSetTransactor.cpp" diff --git a/src/ripple_app/tx/AccountSetTransactor.cpp b/src/ripple_app/transactors/AccountSetTransactor.cpp similarity index 99% rename from src/ripple_app/tx/AccountSetTransactor.cpp rename to src/ripple_app/transactors/AccountSetTransactor.cpp index c2391bcee..f3e797c13 100644 --- a/src/ripple_app/tx/AccountSetTransactor.cpp +++ b/src/ripple_app/transactors/AccountSetTransactor.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + SETUP_LOG (AccountSetTransactor) TER AccountSetTransactor::doApply () @@ -310,4 +312,4 @@ TER AccountSetTransactor::doApply () return tesSUCCESS; } -// vim:ts=4 +} diff --git a/src/ripple_app/tx/AccountSetTransactor.h b/src/ripple_app/transactors/AccountSetTransactor.h similarity index 98% rename from src/ripple_app/tx/AccountSetTransactor.h rename to src/ripple_app/transactors/AccountSetTransactor.h index 6a1255d5a..7c1fb4b98 100644 --- a/src/ripple_app/tx/AccountSetTransactor.h +++ b/src/ripple_app/transactors/AccountSetTransactor.h @@ -20,6 +20,8 @@ #ifndef ACCOUNTSETTRANSACTOR_H #define ACCOUNTSETTRANSACTOR_H +namespace ripple { + class AccountSetTransactor : public Transactor { public: @@ -27,6 +29,7 @@ public: TER doApply (); }; -#endif -// vim:ts=4 +} + +#endif diff --git a/src/ripple_app/tx/ChangeTransactor.cpp b/src/ripple_app/transactors/ChangeTransactor.cpp similarity index 99% rename from src/ripple_app/tx/ChangeTransactor.cpp rename to src/ripple_app/transactors/ChangeTransactor.cpp index 2ee8a758a..0a48ad1d4 100644 --- a/src/ripple_app/tx/ChangeTransactor.cpp +++ b/src/ripple_app/transactors/ChangeTransactor.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + SETUP_LOG (ChangeTransactor) TER ChangeTransactor::doApply () @@ -136,3 +138,5 @@ TER ChangeTransactor::applyFee () WriteLog (lsWARNING, ChangeTransactor) << "Fees have been changed"; return tesSUCCESS; } + +} diff --git a/src/ripple_app/tx/ChangeTransactor.h b/src/ripple_app/transactors/ChangeTransactor.h similarity index 98% rename from src/ripple_app/tx/ChangeTransactor.h rename to src/ripple_app/transactors/ChangeTransactor.h index 841e17faa..6d11320ca 100644 --- a/src/ripple_app/tx/ChangeTransactor.h +++ b/src/ripple_app/transactors/ChangeTransactor.h @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + class ChangeTransactor : public Transactor { public: @@ -43,4 +45,4 @@ private: } }; -// vim:ts=4 +} diff --git a/src/ripple_app/tx/OfferCancelTransactor.cpp b/src/ripple_app/transactors/OfferCancelTransactor.cpp similarity index 99% rename from src/ripple_app/tx/OfferCancelTransactor.cpp rename to src/ripple_app/transactors/OfferCancelTransactor.cpp index 9d639715d..b3e56961c 100644 --- a/src/ripple_app/tx/OfferCancelTransactor.cpp +++ b/src/ripple_app/transactors/OfferCancelTransactor.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + SETUP_LOG (OfferCancelTransactor) TER OfferCancelTransactor::doApply () @@ -67,4 +69,4 @@ TER OfferCancelTransactor::doApply () return terResult; } -// vim:ts=4 +} diff --git a/src/ripple_app/tx/OfferCancelTransactor.h b/src/ripple_app/transactors/OfferCancelTransactor.h similarity index 98% rename from src/ripple_app/tx/OfferCancelTransactor.h rename to src/ripple_app/transactors/OfferCancelTransactor.h index 8cf5093e7..a191592d8 100644 --- a/src/ripple_app/tx/OfferCancelTransactor.h +++ b/src/ripple_app/transactors/OfferCancelTransactor.h @@ -20,6 +20,8 @@ #ifndef OFFERCANCELTRANSACTOR_H #define OFFERCANCELTRANSACTOR_H +namespace ripple { + class OfferCancelTransactor : public Transactor { public: @@ -27,6 +29,7 @@ public: TER doApply (); }; -#endif -// vim:ts=4 +} + +#endif diff --git a/src/ripple_app/tx/OfferCreateTransactor.cpp b/src/ripple_app/transactors/OfferCreateTransactor.cpp similarity index 99% rename from src/ripple_app/tx/OfferCreateTransactor.cpp rename to src/ripple_app/transactors/OfferCreateTransactor.cpp index 17491252d..0aeebca4e 100644 --- a/src/ripple_app/tx/OfferCreateTransactor.cpp +++ b/src/ripple_app/transactors/OfferCreateTransactor.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + SETUP_LOG (OfferCreateTransactor) // Make sure an offer is still valid. If not, mark it unfunded. @@ -749,4 +751,5 @@ TER OfferCreateTransactor::doApply () return terResult; } -// vim:ts=4 +} + diff --git a/src/ripple_app/tx/OfferCreateTransactor.h b/src/ripple_app/transactors/OfferCreateTransactor.h similarity index 99% rename from src/ripple_app/tx/OfferCreateTransactor.h rename to src/ripple_app/transactors/OfferCreateTransactor.h index 1225ac459..ae55ed041 100644 --- a/src/ripple_app/tx/OfferCreateTransactor.h +++ b/src/ripple_app/transactors/OfferCreateTransactor.h @@ -20,6 +20,8 @@ #ifndef __OFFERCREATETRANSACTOR__ #define __OFFERCREATETRANSACTOR__ +namespace ripple { + class OfferCreateTransactor : public Transactor { public: @@ -57,6 +59,6 @@ private: std::set usMissingOffers; }; -#endif +} -// vim:ts=4 +#endif diff --git a/src/ripple_app/tx/PaymentTransactor.cpp b/src/ripple_app/transactors/PaymentTransactor.cpp similarity index 99% rename from src/ripple_app/tx/PaymentTransactor.cpp rename to src/ripple_app/transactors/PaymentTransactor.cpp index 6a5ee788d..926771eba 100644 --- a/src/ripple_app/tx/PaymentTransactor.cpp +++ b/src/ripple_app/transactors/PaymentTransactor.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + SETUP_LOG (PaymentTransactor) #define RIPPLE_PATHS_MAX 6 @@ -262,4 +264,5 @@ TER PaymentTransactor::doApply () return terResult; } -// vim:ts=4 +} + diff --git a/src/ripple_app/tx/PaymentTransactor.h b/src/ripple_app/transactors/PaymentTransactor.h similarity index 98% rename from src/ripple_app/tx/PaymentTransactor.h rename to src/ripple_app/transactors/PaymentTransactor.h index bc0069b8b..044f64d0d 100644 --- a/src/ripple_app/tx/PaymentTransactor.h +++ b/src/ripple_app/transactors/PaymentTransactor.h @@ -20,6 +20,8 @@ #ifndef __PAYMENTTRANSACTOR__ #define __PAYMENTTRANSACTOR__ +namespace ripple { + class PaymentTransactor : public Transactor { public: @@ -27,6 +29,7 @@ public: TER doApply (); }; -#endif -// vim:ts=4 +} + +#endif diff --git a/src/ripple_app/tx/RegularKeySetTransactor.cpp b/src/ripple_app/transactors/RegularKeySetTransactor.cpp similarity index 99% rename from src/ripple_app/tx/RegularKeySetTransactor.cpp rename to src/ripple_app/transactors/RegularKeySetTransactor.cpp index c8c4508d0..ed7d8d2c8 100644 --- a/src/ripple_app/tx/RegularKeySetTransactor.cpp +++ b/src/ripple_app/transactors/RegularKeySetTransactor.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + SETUP_LOG (RegularKeySetTransactor) uint64 RegularKeySetTransactor::calculateBaseFee () @@ -68,4 +70,4 @@ TER RegularKeySetTransactor::doApply () return tesSUCCESS; } -// vim:ts=4 +} diff --git a/src/ripple_app/tx/RegularKeySetTransactor.h b/src/ripple_app/transactors/RegularKeySetTransactor.h similarity index 98% rename from src/ripple_app/tx/RegularKeySetTransactor.h rename to src/ripple_app/transactors/RegularKeySetTransactor.h index 8e88b7c85..c8ebd7b39 100644 --- a/src/ripple_app/tx/RegularKeySetTransactor.h +++ b/src/ripple_app/transactors/RegularKeySetTransactor.h @@ -20,6 +20,8 @@ #ifndef REGULARKEYSETTRANSACTOR_H #define REGULARKEYSETTRANSACTOR_H +namespace ripple { + class RegularKeySetTransactor : public Transactor { uint64 calculateBaseFee (); @@ -28,6 +30,7 @@ public: TER checkFee (); TER doApply (); }; -#endif -// vim:ts=4 +} + +#endif diff --git a/src/ripple_app/tx/Transactor.cpp b/src/ripple_app/transactors/Transactor.cpp similarity index 66% rename from src/ripple_app/tx/Transactor.cpp rename to src/ripple_app/transactors/Transactor.cpp index fc0bf0a18..6d8901742 100644 --- a/src/ripple_app/tx/Transactor.cpp +++ b/src/ripple_app/transactors/Transactor.cpp @@ -17,36 +17,57 @@ */ //============================================================================== -SETUP_LOG (Transactor) +#include "Transactor.h" +#include "ChangeTransactor.h" +#include "OfferCancelTransactor.h" +#include "OfferCreateTransactor.h" +#include "PaymentTransactor.h" +#include "RegularKeySetTransactor.h" +#include "AccountSetTransactor.h" +#include "TrustSetTransactor.h" +#include "WalletAddTransactor.h" -std::unique_ptr Transactor::makeTransactor (const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine) +namespace ripple { + +std::unique_ptr Transactor::makeTransactor ( + SerializedTransaction const& txn, + TransactionEngineParams params, + TransactionEngine* engine) { switch (txn.getTxnType ()) { case ttPAYMENT: - return std::unique_ptr (new PaymentTransactor (txn, params, engine)); + return std::unique_ptr ( + new PaymentTransactor (txn, params, engine)); case ttACCOUNT_SET: - return std::unique_ptr (new AccountSetTransactor (txn, params, engine)); + return std::unique_ptr ( + new AccountSetTransactor (txn, params, engine)); case ttREGULAR_KEY_SET: - return std::unique_ptr (new RegularKeySetTransactor (txn, params, engine)); + return std::unique_ptr ( + new RegularKeySetTransactor (txn, params, engine)); case ttTRUST_SET: - return std::unique_ptr (new TrustSetTransactor (txn, params, engine)); + return std::unique_ptr ( + new TrustSetTransactor (txn, params, engine)); case ttOFFER_CREATE: - return std::unique_ptr (new OfferCreateTransactor (txn, params, engine)); + return std::unique_ptr ( + new OfferCreateTransactor (txn, params, engine)); case ttOFFER_CANCEL: - return std::unique_ptr (new OfferCancelTransactor (txn, params, engine)); + return std::unique_ptr ( + new OfferCancelTransactor (txn, params, engine)); case ttWALLET_ADD: - return std::unique_ptr (new WalletAddTransactor (txn, params, engine)); + return std::unique_ptr ( + new WalletAddTransactor (txn, params, engine)); case ttFEATURE: case ttFEE: - return std::unique_ptr (new ChangeTransactor (txn, params, engine)); + return std::unique_ptr ( + new ChangeTransactor (txn, params, engine)); default: return std::unique_ptr (); @@ -54,15 +75,24 @@ std::unique_ptr Transactor::makeTransactor (const SerializedTransact } -Transactor::Transactor (const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine) : mTxn (txn), mEngine (engine), mParams (params) +Transactor::Transactor ( + SerializedTransaction const& txn, + TransactionEngineParams params, + TransactionEngine* engine, + Journal journal) + : mTxn (txn) + , mEngine (engine) + , mParams (params) + , mHasAuthKey (false) + , mSigMaster (false) + , m_journal (journal) { - mHasAuthKey = false; - mSigMaster = false; } void Transactor::calculateFee () { - mFeeDue = STAmount (mEngine->getLedger ()->scaleFeeLoad (calculateBaseFee (), isSetBit (mParams, tapADMIN))); + mFeeDue = STAmount (mEngine->getLedger ()->scaleFeeLoad ( + calculateBaseFee (), isSetBit (mParams, tapADMIN))); } uint64 Transactor::calculateBaseFee () @@ -80,9 +110,8 @@ TER Transactor::payFee () // Only check fee is sufficient when the ledger is open. if (isSetBit (mParams, tapOPEN_LEDGER) && saPaid < mFeeDue) { - WriteLog (lsINFO, Transactor) << boost::str (boost::format ("applyTransaction: Insufficient fee paid: %s/%s") - % saPaid.getText () - % mFeeDue.getText ()); + m_journal.info << "Insufficient fee paid: " << + saPaid.getText () << "/" << mFeeDue.getText (); return telINSUF_FEE_P; } @@ -96,10 +125,9 @@ TER Transactor::payFee () // Will only write the account back, if the transaction succeeds. if (mSourceBalance < saPaid) { - WriteLog (lsINFO, Transactor) - << boost::str (boost::format ("applyTransaction: Delay: insufficient balance: balance=%s paid=%s") - % mSourceBalance.getText () - % saPaid.getText ()); + m_journal.info << "Insufficient balance:" << + " balance=" << mSourceBalance.getText () << + " paid=" << saPaid.getText (); return terINSUF_FEE_B; } @@ -128,13 +156,12 @@ TER Transactor::checkSig () } else if (mHasAuthKey) { - WriteLog (lsINFO, Transactor) << "applyTransaction: Delay: Not authorized to use account."; - + m_journal.info << "applyTransaction: Delay: Not authorized to use account."; return tefBAD_AUTH; } else { - WriteLog (lsINFO, Transactor) << "applyTransaction: Invalid: Not authorized to use account."; + m_journal.info << "applyTransaction: Invalid: Not authorized to use account."; return temBAD_AUTH_MASTER; } @@ -147,13 +174,13 @@ TER Transactor::checkSeq () uint32 t_seq = mTxn.getSequence (); uint32 a_seq = mTxnAccount->getFieldU32 (sfSequence); - WriteLog (lsTRACE, Transactor) << "Aseq=" << a_seq << ", Tseq=" << t_seq; + m_journal.trace << "Aseq=" << a_seq << ", Tseq=" << t_seq; if (t_seq != a_seq) { if (a_seq < t_seq) { - WriteLog (lsINFO, Transactor) << "applyTransaction: future sequence number"; + m_journal.info << "apply: transaction has future sequence number"; return terPRE_SEQ; } @@ -165,7 +192,7 @@ TER Transactor::checkSeq () return tefALREADY; } - WriteLog (lsWARNING, Transactor) << "applyTransaction: past sequence number"; + m_journal.warning << "apply: transaction has past sequence number"; return tefPAST_SEQ; } @@ -198,8 +225,7 @@ TER Transactor::preCheck () if (!mTxnAccountID) { - WriteLog (lsWARNING, Transactor) << "applyTransaction: bad source id"; - + m_journal.warning << "apply: bad transaction source id"; return temBAD_SRC_ACCOUNT; } @@ -216,7 +242,7 @@ TER Transactor::preCheck () if (mTxn.isKnownBad () || (!isSetBit (mParams, tapNO_CHECK_SIGN) && !mTxn.checkSign (mSigningPubKey))) { mTxn.setBad (); - WriteLog (lsWARNING, Transactor) << "applyTransaction: Invalid transaction: bad signature"; + m_journal.warning << "apply: Invalid transaction (bad signature)"; return temINVALID; } @@ -228,26 +254,29 @@ TER Transactor::preCheck () TER Transactor::apply () { - TER terResult = tesSUCCESS; - terResult = preCheck (); + TER terResult (preCheck ()); - if (terResult != tesSUCCESS) return (terResult); + if (terResult != tesSUCCESS) + return (terResult); + // Restructure this to avoid the dependency on LedgerBase::mLock Ledger::ScopedLockType sl (mEngine->getLedger ()->mLock, __FILE__, __LINE__); - mTxnAccount = mEngine->entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (mTxnAccountID)); + mTxnAccount = mEngine->entryCache (ltACCOUNT_ROOT, + Ledger::getAccountRootIndex (mTxnAccountID)); calculateFee (); // Find source account - // If are only forwarding, due to resource limitations, we might verifying only some transactions, this would be probabilistic. + // If are only forwarding, due to resource limitations, we might verifying + // only some transactions, this would be probabilistic. if (!mTxnAccount) { if (mustHaveValidAccount ()) { - WriteLog (lsTRACE, Transactor) << boost::str (boost::format ("applyTransaction: Delay transaction: source account does not exist: %s") % - mTxn.getSourceAccount ().humanAccountID ()); - + m_journal.trace << + "apply: delay transaction: source account does not exist " << + mTxn.getSourceAccount ().humanAccountID (); return terNO_ACCOUNT; } } @@ -276,4 +305,4 @@ TER Transactor::apply () return doApply (); } -// vim:ts=4 +} diff --git a/src/ripple_app/tx/Transactor.h b/src/ripple_app/transactors/Transactor.h similarity index 82% rename from src/ripple_app/tx/Transactor.h rename to src/ripple_app/transactors/Transactor.h index c85bf6a46..e643aab55 100644 --- a/src/ripple_app/tx/Transactor.h +++ b/src/ripple_app/transactors/Transactor.h @@ -20,17 +20,20 @@ #ifndef __TRANSACTOR__ #define __TRANSACTOR__ +namespace ripple { + class Transactor { public: - typedef boost::shared_ptr pointer; - - static std::unique_ptr makeTransactor (const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine); + static std::unique_ptr makeTransactor ( + SerializedTransaction const& txn, + TransactionEngineParams params, + TransactionEngine* engine); TER apply (); protected: - const SerializedTransaction& mTxn; + SerializedTransaction const& mTxn; TransactionEngine* mEngine; TransactionEngineParams mParams; @@ -43,6 +46,8 @@ protected: bool mSigMaster; RippleAddress mSigningPubKey; + Journal m_journal; + virtual TER preCheck (); virtual TER checkSeq (); virtual TER payFee (); @@ -55,7 +60,11 @@ protected: virtual TER checkSig (); virtual TER doApply () = 0; - Transactor (const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine); + Transactor ( + const SerializedTransaction& txn, + TransactionEngineParams params, + TransactionEngine* engine, + Journal journal = Journal ()); virtual bool mustHaveValidAccount () { @@ -63,6 +72,6 @@ protected: } }; -#endif +} -// vim:ts=4 +#endif diff --git a/src/ripple_app/tx/TrustSetTransactor.cpp b/src/ripple_app/transactors/TrustSetTransactor.cpp similarity index 99% rename from src/ripple_app/tx/TrustSetTransactor.cpp rename to src/ripple_app/transactors/TrustSetTransactor.cpp index 38f718a16..a95bde585 100644 --- a/src/ripple_app/tx/TrustSetTransactor.cpp +++ b/src/ripple_app/transactors/TrustSetTransactor.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + SETUP_LOG (TrustSetTransactor) TER TrustSetTransactor::doApply () @@ -365,4 +367,4 @@ TER TrustSetTransactor::doApply () return terResult; } -// vim:ts=4 +} diff --git a/src/ripple_app/tx/TrustSetTransactor.h b/src/ripple_app/transactors/TrustSetTransactor.h similarity index 98% rename from src/ripple_app/tx/TrustSetTransactor.h rename to src/ripple_app/transactors/TrustSetTransactor.h index cf9e442f7..f405f6ed6 100644 --- a/src/ripple_app/tx/TrustSetTransactor.h +++ b/src/ripple_app/transactors/TrustSetTransactor.h @@ -20,6 +20,8 @@ #ifndef TRUSTSETTRANSACTOR_H #define TRUSTSETTRANSACTOR_H +namespace ripple { + class TrustSetTransactor : public Transactor { public: @@ -27,6 +29,7 @@ public: TER doApply (); }; -#endif -// vim:ts=4 +} + +#endif diff --git a/src/ripple_app/tx/WalletAddTransactor.cpp b/src/ripple_app/transactors/WalletAddTransactor.cpp similarity index 99% rename from src/ripple_app/tx/WalletAddTransactor.cpp rename to src/ripple_app/transactors/WalletAddTransactor.cpp index 3172631ae..4977214a4 100644 --- a/src/ripple_app/tx/WalletAddTransactor.cpp +++ b/src/ripple_app/transactors/WalletAddTransactor.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +namespace ripple { + SETUP_LOG (WalletAddTransactor) TER WalletAddTransactor::doApply () @@ -90,4 +92,4 @@ TER WalletAddTransactor::doApply () return tesSUCCESS; } -// vim:ts=4 +} diff --git a/src/ripple_app/tx/WalletAddTransactor.h b/src/ripple_app/transactors/WalletAddTransactor.h similarity index 98% rename from src/ripple_app/tx/WalletAddTransactor.h rename to src/ripple_app/transactors/WalletAddTransactor.h index 7bc2b3ada..da8778dd0 100644 --- a/src/ripple_app/tx/WalletAddTransactor.h +++ b/src/ripple_app/transactors/WalletAddTransactor.h @@ -20,6 +20,8 @@ #ifndef WALLETADDTRANSACTOR_H #define WALLETADDTRANSACTOR_H +namespace ripple { + class WalletAddTransactor : public Transactor { public: @@ -27,6 +29,7 @@ public: TER doApply (); }; -#endif -// vim:ts=4 +} + +#endif diff --git a/src/ripple_app/tx/TransactionEngine.cpp b/src/ripple_app/tx/TransactionEngine.cpp index 7dff78461..bea3d314f 100644 --- a/src/ripple_app/tx/TransactionEngine.cpp +++ b/src/ripple_app/tx/TransactionEngine.cpp @@ -109,119 +109,117 @@ TER TransactionEngine::applyTransaction (const SerializedTransaction& txn, Trans std::unique_ptr transactor = Transactor::makeTransactor (txn, params, this); - if (transactor.get () != NULL) - { - TER terResult = transactor->apply (); - std::string strToken; - std::string strHuman; - - transResultInfo (terResult, strToken, strHuman); - - WriteLog (lsINFO, TransactionEngine) << "applyTransaction: terResult=" << strToken << " : " << terResult << " : " << strHuman; - - if (isTesSuccess (terResult)) - didApply = true; - else if (isTecClaim (terResult) && !isSetBit (params, tapRETRY)) - { - // only claim the transaction fee - WriteLog (lsDEBUG, TransactionEngine) << "Reprocessing to only claim fee"; - mNodes.clear (); - - SLE::pointer txnAcct = entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (txn.getSourceAccount ())); - - if (!txnAcct) - terResult = terNO_ACCOUNT; - else - { - uint32 t_seq = txn.getSequence (); - uint32 a_seq = txnAcct->getFieldU32 (sfSequence); - - if (a_seq < t_seq) - terResult = terPRE_SEQ; - else if (a_seq > t_seq) - terResult = tefPAST_SEQ; - else - { - STAmount fee = txn.getTransactionFee (); - STAmount balance = txnAcct->getFieldAmount (sfBalance); - - if (balance < fee) - terResult = terINSUF_FEE_B; - else - { - txnAcct->setFieldAmount (sfBalance, balance - fee); - txnAcct->setFieldU32 (sfSequence, t_seq + 1); - entryModify (txnAcct); - didApply = true; - } - } - } - } - else - WriteLog (lsDEBUG, TransactionEngine) << "Not applying transaction " << txID; - - if (didApply) - { - if (!checkInvariants (terResult, txn, params)) - { - WriteLog (lsFATAL, TransactionEngine) << "Transaction violates invariants"; - WriteLog (lsFATAL, TransactionEngine) << txn.getJson (0); - WriteLog (lsFATAL, TransactionEngine) << transToken (terResult) << ": " << transHuman (terResult); - WriteLog (lsFATAL, TransactionEngine) << mNodes.getJson (0); - didApply = false; - terResult = tefINTERNAL; - } - else - { - // Transaction succeeded fully or (retries are not allowed and the transaction could claim a fee) - Serializer m; - mNodes.calcRawMeta (m, terResult, mTxnSeq++); - - txnWrite (); - - Serializer s; - txn.add (s); - - if (isSetBit (params, tapOPEN_LEDGER)) - { - if (!mLedger->addTransaction (txID, s)) - { - WriteLog (lsFATAL, TransactionEngine) << "Tried to add transaction to open ledger that already had it"; - assert (false); - throw std::runtime_error ("Duplicate transaction applied"); - } - } - else - { - if (!mLedger->addTransaction (txID, s, m)) - { - WriteLog (lsFATAL, TransactionEngine) << "Tried to add transaction to ledger that already had it"; - assert (false); - throw std::runtime_error ("Duplicate transaction applied to closed ledger"); - } - - // Charge whatever fee they specified. - STAmount saPaid = txn.getTransactionFee (); - mLedger->destroyCoins (saPaid.getNValue ()); - } - } - } - - mTxnAccount.reset (); - mNodes.clear (); - - if (!isSetBit (params, tapOPEN_LEDGER) && isTemMalformed (terResult)) - { - // XXX Malformed or failed transaction in closed ledger must bow out. - } - - return terResult; - } - else + if (transactor.get () == NULL) { WriteLog (lsWARNING, TransactionEngine) << "applyTransaction: Invalid transaction: unknown transaction type"; return temUNKNOWN; } + + TER terResult = transactor->apply (); + std::string strToken; + std::string strHuman; + + transResultInfo (terResult, strToken, strHuman); + + WriteLog (lsINFO, TransactionEngine) << "applyTransaction: terResult=" << strToken << " : " << terResult << " : " << strHuman; + + if (isTesSuccess (terResult)) + didApply = true; + else if (isTecClaim (terResult) && !isSetBit (params, tapRETRY)) + { + // only claim the transaction fee + WriteLog (lsDEBUG, TransactionEngine) << "Reprocessing to only claim fee"; + mNodes.clear (); + + SLE::pointer txnAcct = entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (txn.getSourceAccount ())); + + if (!txnAcct) + terResult = terNO_ACCOUNT; + else + { + uint32 t_seq = txn.getSequence (); + uint32 a_seq = txnAcct->getFieldU32 (sfSequence); + + if (a_seq < t_seq) + terResult = terPRE_SEQ; + else if (a_seq > t_seq) + terResult = tefPAST_SEQ; + else + { + STAmount fee = txn.getTransactionFee (); + STAmount balance = txnAcct->getFieldAmount (sfBalance); + + if (balance < fee) + terResult = terINSUF_FEE_B; + else + { + txnAcct->setFieldAmount (sfBalance, balance - fee); + txnAcct->setFieldU32 (sfSequence, t_seq + 1); + entryModify (txnAcct); + didApply = true; + } + } + } + } + else + WriteLog (lsDEBUG, TransactionEngine) << "Not applying transaction " << txID; + + if (didApply) + { + if (!checkInvariants (terResult, txn, params)) + { + WriteLog (lsFATAL, TransactionEngine) << "Transaction violates invariants"; + WriteLog (lsFATAL, TransactionEngine) << txn.getJson (0); + WriteLog (lsFATAL, TransactionEngine) << transToken (terResult) << ": " << transHuman (terResult); + WriteLog (lsFATAL, TransactionEngine) << mNodes.getJson (0); + didApply = false; + terResult = tefINTERNAL; + } + else + { + // Transaction succeeded fully or (retries are not allowed and the transaction could claim a fee) + Serializer m; + mNodes.calcRawMeta (m, terResult, mTxnSeq++); + + txnWrite (); + + Serializer s; + txn.add (s); + + if (isSetBit (params, tapOPEN_LEDGER)) + { + if (!mLedger->addTransaction (txID, s)) + { + WriteLog (lsFATAL, TransactionEngine) << "Tried to add transaction to open ledger that already had it"; + assert (false); + throw std::runtime_error ("Duplicate transaction applied"); + } + } + else + { + if (!mLedger->addTransaction (txID, s, m)) + { + WriteLog (lsFATAL, TransactionEngine) << "Tried to add transaction to ledger that already had it"; + assert (false); + throw std::runtime_error ("Duplicate transaction applied to closed ledger"); + } + + // Charge whatever fee they specified. + STAmount saPaid = txn.getTransactionFee (); + mLedger->destroyCoins (saPaid.getNValue ()); + } + } + } + + mTxnAccount.reset (); + mNodes.clear (); + + if (!isSetBit (params, tapOPEN_LEDGER) && isTemMalformed (terResult)) + { + // XXX Malformed or failed transaction in closed ledger must bow out. + } + + return terResult; } // vim:ts=4