From 08a81a0ab9462f12b361f5cfc87b5d142780cf9d Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 19 Nov 2014 07:22:11 -0800 Subject: [PATCH] Tidy up the structure of sources in protocol/: Split out and rename STValidation Split out and rename STBlob Split out and rename STAccount Split out STPathSet Split STVector256 and move UintTypes to protocol/ Rename to STBase Rename to STLedgerEntry Rename to SOTemplate Rename to STTx Remove obsolete AgedHistory Remove types.h and add missing includes Remove unnecessary includes in app.h Remove unnecessary includes in app.h Remove include app.h from app1.cpp --- Builds/VisualStudio2013/RippleD.vcxproj | 88 +++--- .../VisualStudio2013/RippleD.vcxproj.filters | 108 +++---- src/ripple/app/book/Offer.h | 2 +- src/ripple/app/consensus/DisputedTx.h | 5 + src/ripple/app/consensus/LedgerConsensus.cpp | 38 ++- src/ripple/app/consensus/LedgerConsensus.h | 10 + src/ripple/app/data/Database.h | 2 + src/ripple/app/ledger/AcceptedLedgerTx.cpp | 6 +- src/ripple/app/ledger/AcceptedLedgerTx.h | 8 +- src/ripple/app/ledger/InboundLedger.h | 3 + src/ripple/app/ledger/InboundLedgers.h | 2 + src/ripple/app/ledger/Ledger.cpp | 22 +- src/ripple/app/ledger/Ledger.h | 7 +- src/ripple/app/ledger/LedgerCleaner.cpp | 2 + src/ripple/app/ledger/LedgerEntrySet.cpp | 4 +- src/ripple/app/ledger/LedgerHistory.h | 1 + src/ripple/app/ledger/LedgerMaster.cpp | 6 +- src/ripple/app/ledger/LedgerMaster.h | 3 +- src/ripple/app/ledger/OrderBookDB.h | 2 + src/ripple/app/main/Application.cpp | 2 +- src/ripple/app/main/Application.h | 4 +- src/ripple/app/main/Main.cpp | 1 + src/ripple/app/misc/AccountState.cpp | 2 +- src/ripple/app/misc/AccountState.h | 8 +- src/ripple/app/misc/AmendmentTableImpl.cpp | 2 +- src/ripple/app/misc/CanonicalTXSet.cpp | 2 +- src/ripple/app/misc/CanonicalTXSet.h | 10 +- src/ripple/app/misc/FeeVoteImpl.cpp | 4 +- src/ripple/app/misc/IHashRouter.h | 3 + src/ripple/app/misc/NetworkOPs.cpp | 26 +- src/ripple/app/misc/NetworkOPs.h | 14 +- src/ripple/app/misc/Validations.cpp | 6 +- src/ripple/app/misc/Validations.h | 9 +- src/ripple/app/paths/Node.h | 2 +- src/ripple/app/paths/PathRequest.cpp | 2 +- src/ripple/app/paths/PathRequest.h | 3 + src/ripple/app/paths/PathRequests.h | 2 + src/ripple/app/paths/RippleLineCache.h | 5 + src/ripple/app/paths/RippleState.cpp | 4 +- src/ripple/app/paths/RippleState.h | 12 +- src/ripple/app/shamap/SHAMapSyncFilters.cpp | 5 +- src/ripple/app/transactors/AddWallet.cpp | 4 +- src/ripple/app/transactors/CancelOffer.cpp | 4 +- src/ripple/app/transactors/CancelTicket.cpp | 4 +- src/ripple/app/transactors/Change.cpp | 4 +- src/ripple/app/transactors/CreateOffer.cpp | 4 +- src/ripple/app/transactors/CreateTicket.cpp | 4 +- src/ripple/app/transactors/Payment.cpp | 4 +- src/ripple/app/transactors/SetAccount.cpp | 4 +- src/ripple/app/transactors/SetRegularKey.cpp | 4 +- src/ripple/app/transactors/SetTrust.cpp | 4 +- src/ripple/app/transactors/Transactor.cpp | 24 +- src/ripple/app/transactors/Transactor.h | 6 +- src/ripple/app/tx/LocalTxs.cpp | 8 +- src/ripple/app/tx/LocalTxs.h | 5 +- src/ripple/app/tx/Transaction.cpp | 8 +- src/ripple/app/tx/Transaction.h | 9 +- src/ripple/app/tx/TransactionAcquire.h | 2 + src/ripple/app/tx/TransactionCheck.cpp | 2 +- src/ripple/app/tx/TransactionEngine.cpp | 4 +- src/ripple/app/tx/TransactionEngine.h | 15 +- src/ripple/app/tx/TransactionMaster.cpp | 8 +- src/ripple/app/tx/TransactionMaster.h | 2 +- src/ripple/app/tx/TransactionMeta.cpp | 6 +- src/ripple/app/tx/TransactionMeta.h | 2 +- src/ripple/overlay/impl/PeerImp.cpp | 14 +- src/ripple/overlay/impl/PeerImp.h | 4 +- src/ripple/proto/ripple.proto | 2 +- src/ripple/protocol/Indexes.h | 3 +- src/ripple/protocol/KnownFormats.h | 2 +- src/ripple/protocol/README.md | 10 + src/ripple/protocol/RippleAddress.h | 2 +- ...erializedObjectTemplate.h => SOTemplate.h} | 12 +- src/ripple/protocol/STAccount.h | 90 ++++++ src/ripple/protocol/STAmount.h | 10 +- src/ripple/protocol/STArray.h | 12 +- src/ripple/protocol/STBase.h | 162 +++++++++++ src/ripple/protocol/STBitString.h | 18 +- src/ripple/protocol/STBlob.h | 106 +++++++ src/ripple/protocol/STInteger.h | 12 +- .../STLedgerEntry.h} | 45 +-- src/ripple/protocol/STObject.h | 84 +++--- .../{SerializedTypes.h => STPathSet.h} | 268 +----------------- .../STTx.h} | 26 +- .../STValidation.h} | 14 +- src/ripple/protocol/STVector256.h | 128 +++++++++ src/ripple/protocol/SerializedType.h | 236 --------------- src/ripple/{types => protocol}/UintTypes.h | 0 src/ripple/protocol/impl/Indexes.cpp | 7 - ...lizedObjectTemplate.cpp => SOTemplate.cpp} | 2 +- src/ripple/protocol/impl/STAccount.cpp | 68 +++++ src/ripple/protocol/impl/STAmount.cpp | 16 +- src/ripple/protocol/impl/STArray.cpp | 6 +- src/ripple/protocol/impl/STBase.cpp | 181 ++++++++++++ src/ripple/protocol/impl/STBlob.cpp | 47 +++ src/ripple/protocol/impl/STInteger.cpp | 2 +- .../impl/STLedgerEntry.cpp} | 45 +-- src/ripple/protocol/impl/STObject.cpp | 77 ++--- src/ripple/protocol/impl/STParsedJSON.cpp | 10 +- .../{SerializedTypes.cpp => STPathSet.cpp} | 179 +----------- .../impl/STTx.cpp} | 59 ++-- .../impl/STValidation.cpp} | 31 +- src/ripple/protocol/impl/STVector256.cpp | 83 ++++++ .../{types => protocol}/impl/UintTypes.cpp | 4 +- src/ripple/rpc/handlers/LogLevel.cpp | 1 + src/ripple/rpc/handlers/Submit.cpp | 4 +- src/ripple/rpc/impl/TransactionSign.cpp | 4 +- src/ripple/types/AgedHistory.h | 74 ----- src/ripple/types/ByteOrder.h | 12 + src/ripple/types/Issue.h | 2 +- src/ripple/types/impl/ByteOrder.cpp | 11 + src/ripple/types/impl/Issue.cpp | 5 +- src/ripple/unity/app.h | 33 +-- src/ripple/unity/app1.cpp | 3 - src/ripple/unity/app7.cpp | 1 - src/ripple/unity/app8.cpp | 1 - src/ripple/unity/protocol.cpp | 23 +- src/ripple/unity/types.cpp | 17 -- src/ripple/unity/types.h | 61 ---- 119 files changed, 1534 insertions(+), 1383 deletions(-) rename src/ripple/protocol/{SerializedObjectTemplate.h => SOTemplate.h} (90%) create mode 100644 src/ripple/protocol/STAccount.h create mode 100644 src/ripple/protocol/STBase.h create mode 100644 src/ripple/protocol/STBlob.h rename src/ripple/{app/misc/SerializedLedger.h => protocol/STLedgerEntry.h} (67%) rename src/ripple/protocol/{SerializedTypes.h => STPathSet.h} (52%) rename src/ripple/{app/misc/SerializedTransaction.h => protocol/STTx.h} (83%) rename src/ripple/{app/ledger/SerializedValidation.h => protocol/STValidation.h} (86%) create mode 100644 src/ripple/protocol/STVector256.h delete mode 100644 src/ripple/protocol/SerializedType.h rename src/ripple/{types => protocol}/UintTypes.h (100%) rename src/ripple/protocol/impl/{SerializedObjectTemplate.cpp => SOTemplate.cpp} (97%) create mode 100644 src/ripple/protocol/impl/STAccount.cpp create mode 100644 src/ripple/protocol/impl/STBase.cpp create mode 100644 src/ripple/protocol/impl/STBlob.cpp rename src/ripple/{app/misc/SerializedLedger.cpp => protocol/impl/STLedgerEntry.cpp} (80%) rename src/ripple/protocol/impl/{SerializedTypes.cpp => STPathSet.cpp} (56%) rename src/ripple/{app/misc/SerializedTransaction.cpp => protocol/impl/STTx.cpp} (85%) rename src/ripple/{app/ledger/SerializedValidation.cpp => protocol/impl/STValidation.cpp} (83%) create mode 100644 src/ripple/protocol/impl/STVector256.cpp rename src/ripple/{types => protocol}/impl/UintTypes.cpp (98%) delete mode 100644 src/ripple/types/AgedHistory.h delete mode 100644 src/ripple/unity/types.h diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 8a74a82bf1..3e9f5f371c 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -272,8 +272,6 @@ - - @@ -1771,11 +1769,6 @@ - - True - - - True @@ -1864,16 +1857,6 @@ - - True - - - - - True - - - True @@ -2646,18 +2629,18 @@ True - - True - - - True - True True + + True + + + True + True @@ -2667,21 +2650,45 @@ True + + True + + + True + True + + True + True True + + True + + + True + + + True + + + True + True True + + True + @@ -2696,34 +2703,48 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + Document protoc --cpp_out=..\..\build\proto --proto_path=%(RelativeDir) %(Identity) @@ -3123,8 +3144,6 @@ - - @@ -3156,9 +3175,6 @@ True - - True - @@ -3181,8 +3197,6 @@ - - @@ -3269,8 +3283,6 @@ - - diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 2b93aa3a29..6ca15cb800 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -774,9 +774,6 @@ beast\container\tests - - beast - beast\crypto @@ -2643,12 +2640,6 @@ ripple\app\ledger - - ripple\app\ledger - - - ripple\app\ledger - ripple\app\main @@ -2757,18 +2748,6 @@ ripple\app\misc - - ripple\app\misc - - - ripple\app\misc - - - ripple\app\misc - - - ripple\app\misc - ripple\app\misc @@ -3714,18 +3693,18 @@ ripple\protocol\impl - - ripple\protocol\impl - - - ripple\protocol\impl - ripple\protocol\impl ripple\protocol\impl + + ripple\protocol\impl + + + ripple\protocol\impl + ripple\protocol\impl @@ -3735,21 +3714,45 @@ ripple\protocol\impl + + ripple\protocol\impl + + + ripple\protocol\impl + ripple\protocol\impl + + ripple\protocol\impl + ripple\protocol\impl ripple\protocol\impl + + ripple\protocol\impl + + + ripple\protocol\impl + + + ripple\protocol\impl + + + ripple\protocol\impl + ripple\protocol\impl ripple\protocol\impl + + ripple\protocol\impl + ripple\protocol @@ -3771,39 +3774,57 @@ ripple\protocol - - ripple\protocol - - - ripple\protocol - - - ripple\protocol - ripple\protocol ripple\protocol + + ripple\protocol + + + ripple\protocol + ripple\protocol ripple\protocol + + ripple\protocol + ripple\protocol + + ripple\protocol + ripple\protocol + + ripple\protocol + ripple\protocol ripple\protocol + + ripple\protocol + + + ripple\protocol + + + ripple\protocol + + + ripple\protocol + ripple\protocol @@ -3813,6 +3834,9 @@ ripple\protocol + + ripple\protocol + ripple\proto @@ -4260,9 +4284,6 @@ ripple\sitefiles - - ripple\types - ripple\types @@ -4302,9 +4323,6 @@ ripple\types\impl - - ripple\types\impl - ripple\types @@ -4338,9 +4356,6 @@ ripple\types - - ripple\types - ripple\unity @@ -4455,9 +4470,6 @@ ripple\unity - - ripple\unity - ripple\unity diff --git a/src/ripple/app/book/Offer.h b/src/ripple/app/book/Offer.h index 38b847b9ff..f5aca5bc95 100644 --- a/src/ripple/app/book/Offer.h +++ b/src/ripple/app/book/Offer.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/src/ripple/app/consensus/DisputedTx.h b/src/ripple/app/consensus/DisputedTx.h index f4720af151..8b187233b0 100644 --- a/src/ripple/app/consensus/DisputedTx.h +++ b/src/ripple/app/consensus/DisputedTx.h @@ -20,6 +20,11 @@ #ifndef RIPPLE_DISPUTEDTX_H #define RIPPLE_DISPUTEDTX_H +#include +#include +#include +#include + namespace ripple { /** A transaction discovered to be in dispute during conensus. diff --git a/src/ripple/app/consensus/LedgerConsensus.cpp b/src/ripple/app/consensus/LedgerConsensus.cpp index 94ca6c22c1..9bbc6370b5 100644 --- a/src/ripple/app/consensus/LedgerConsensus.cpp +++ b/src/ripple/app/consensus/LedgerConsensus.cpp @@ -17,6 +17,18 @@ */ //============================================================================== +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -24,7 +36,9 @@ #include #include #include -#include +#include +#include + namespace ripple { @@ -1071,8 +1085,8 @@ private: { // Build validation uint256 signingHash; - SerializedValidation::pointer v = - std::make_shared + STValidation::pointer v = + std::make_shared (newLCLHash, getApp().getOPs ().getValidationTimeNC () , mValPublic, mProposing); v->setFieldU32 (sfLedgerSequence, newLCL->getLedgerSeq ()); @@ -1129,8 +1143,8 @@ private: << "Test applying disputed transaction that did" << " not get in"; SerializerIterator sit (it.second->peekTransaction ()); - SerializedTransaction::pointer txn - = std::make_shared(sit); + STTx::pointer txn + = std::make_shared(sit); retriableTransactions.push_back (txn); anyDisputes = true; @@ -1467,8 +1481,8 @@ private: try { SerializerIterator sit (item->peekSerializer ()); - SerializedTransaction::pointer txn - = std::make_shared(sit); + STTx::pointer txn + = std::make_shared(sit); if (applyTransaction (engine, txn, openLgr, true) == resultRetry) { @@ -1551,7 +1565,7 @@ private: @return One of resultSuccess, resultFail or resultRetry. */ int applyTransaction (TransactionEngine& engine - , SerializedTransaction::ref txn, bool openLedger, bool retryAssured) + , STTx::ref txn, bool openLedger, bool retryAssured) { // Returns false if the transaction has need not be retried. TransactionEngineParams parms = openLedger ? tapOPEN_LEDGER : tapNONE; @@ -2002,7 +2016,7 @@ private: return; } - SerializedValidation::pointer lastVal + STValidation::pointer lastVal = getApp().getOPs ().getLastValidation (); if (lastVal) @@ -2017,8 +2031,8 @@ private: } uint256 signingHash; - SerializedValidation::pointer v - = std::make_shared + STValidation::pointer v + = std::make_shared (mPreviousLedger->getHash () , getApp().getOPs ().getValidationTimeNC (), mValPublic, false); addLoad(v); @@ -2073,7 +2087,7 @@ private: /** Add our load fee to our validation */ - void addLoad(SerializedValidation::ref val) + void addLoad(STValidation::ref val) { std::uint32_t fee = std::max( getApp().getFeeTrack().getLocalFee(), diff --git a/src/ripple/app/consensus/LedgerConsensus.h b/src/ripple/app/consensus/LedgerConsensus.h index 27e569799a..7d30470056 100644 --- a/src/ripple/app/consensus/LedgerConsensus.h +++ b/src/ripple/app/consensus/LedgerConsensus.h @@ -20,6 +20,16 @@ #ifndef RIPPLE_LEDGERCONSENSUS_H #define RIPPLE_LEDGERCONSENSUS_H +#include +#include +#include +#include +#include +#include +#include +#include +#include + namespace ripple { /** Manager for achieving consensus on the next ledger. diff --git a/src/ripple/app/data/Database.h b/src/ripple/app/data/Database.h index ed3f40adbc..4d98a9768d 100644 --- a/src/ripple/app/data/Database.h +++ b/src/ripple/app/data/Database.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_DATABASE_H_INCLUDED #define RIPPLE_DATABASE_H_INCLUDED +#include + namespace ripple { // VFALCO Get rid of these macros diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.cpp b/src/ripple/app/ledger/AcceptedLedgerTx.cpp index 387626189b..748eaae1b3 100644 --- a/src/ripple/app/ledger/AcceptedLedgerTx.cpp +++ b/src/ripple/app/ledger/AcceptedLedgerTx.cpp @@ -29,7 +29,7 @@ AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger, SerializerIterator& sit) Serializer txnSer (sit.getVL ()); SerializerIterator txnIt (txnSer); - mTxn = std::make_shared (std::ref (txnIt)); + mTxn = std::make_shared (std::ref (txnIt)); mRawMeta = sit.getVL (); mMeta = std::make_shared (mTxn->getTransactionID (), ledger->getLedgerSeq (), mRawMeta); @@ -39,7 +39,7 @@ AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger, SerializerIterator& sit) } AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger, - SerializedTransaction::ref txn, TransactionMetaSet::ref met) + STTx::ref txn, TransactionMetaSet::ref met) : mLedger (ledger) , mTxn (txn) , mMeta (met) @@ -50,7 +50,7 @@ AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger, } AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger, - SerializedTransaction::ref txn, TER result) + STTx::ref txn, TER result) : mLedger (ledger) , mTxn (txn) , mResult (result) diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.h b/src/ripple/app/ledger/AcceptedLedgerTx.h index a17966d18b..0177ae03d5 100644 --- a/src/ripple/app/ledger/AcceptedLedgerTx.h +++ b/src/ripple/app/ledger/AcceptedLedgerTx.h @@ -49,11 +49,11 @@ public: public: AcceptedLedgerTx (Ledger::ref ledger, SerializerIterator& sit); - AcceptedLedgerTx (Ledger::ref ledger, SerializedTransaction::ref, + AcceptedLedgerTx (Ledger::ref ledger, STTx::ref, TransactionMetaSet::ref); - AcceptedLedgerTx (Ledger::ref ledger, SerializedTransaction::ref, TER result); + AcceptedLedgerTx (Ledger::ref ledger, STTx::ref, TER result); - SerializedTransaction::ref getTxn () const + STTx::ref getTxn () const { return mTxn; } @@ -99,7 +99,7 @@ public: private: Ledger::pointer mLedger; - SerializedTransaction::pointer mTxn; + STTx::pointer mTxn; TransactionMetaSet::pointer mMeta; TER mResult; std::vector mAffected; diff --git a/src/ripple/app/ledger/InboundLedger.h b/src/ripple/app/ledger/InboundLedger.h index 48d7633daf..8057accf33 100644 --- a/src/ripple/app/ledger/InboundLedger.h +++ b/src/ripple/app/ledger/InboundLedger.h @@ -20,6 +20,9 @@ #ifndef RIPPLE_INBOUNDLEDGER_H #define RIPPLE_INBOUNDLEDGER_H +#include +#include + namespace ripple { // VFALCO TODO Rename to InboundLedger diff --git a/src/ripple/app/ledger/InboundLedgers.h b/src/ripple/app/ledger/InboundLedgers.h index f933c32f68..87394d3005 100644 --- a/src/ripple/app/ledger/InboundLedgers.h +++ b/src/ripple/app/ledger/InboundLedgers.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_INBOUNDLEDGERS_H #define RIPPLE_INBOUNDLEDGERS_H +#include +#include #include #include // diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 6d3ac4c3f6..4d362edee7 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -483,25 +483,25 @@ Transaction::pointer Ledger::getTransaction (uint256 const& transID) const return txn; } -SerializedTransaction::pointer Ledger::getSTransaction ( +STTx::pointer Ledger::getSTransaction ( SHAMapItem::ref item, SHAMapTreeNode::TNType type) { SerializerIterator sit (item->peekSerializer ()); if (type == SHAMapTreeNode::tnTRANSACTION_NM) - return std::make_shared (sit); + return std::make_shared (sit); if (type == SHAMapTreeNode::tnTRANSACTION_MD) { Serializer sTxn (sit.getVL ()); SerializerIterator tSit (sTxn); - return std::make_shared (tSit); + return std::make_shared (tSit); } - return SerializedTransaction::pointer (); + return STTx::pointer (); } -SerializedTransaction::pointer Ledger::getSMTransaction ( +STTx::pointer Ledger::getSMTransaction ( SHAMapItem::ref item, SHAMapTreeNode::TNType type, TransactionMetaSet::pointer& txMeta) const { @@ -510,7 +510,7 @@ SerializedTransaction::pointer Ledger::getSMTransaction ( if (type == SHAMapTreeNode::tnTRANSACTION_NM) { txMeta.reset (); - return std::make_shared (sit); + return std::make_shared (sit); } else if (type == SHAMapTreeNode::tnTRANSACTION_MD) { @@ -519,11 +519,11 @@ SerializedTransaction::pointer Ledger::getSMTransaction ( txMeta = std::make_shared ( item->getTag (), mLedgerSeq, sit.getVL ()); - return std::make_shared (tSit); + return std::make_shared (tSit); } txMeta.reset (); - return SerializedTransaction::pointer (); + return STTx::pointer (); } bool Ledger::getTransaction ( @@ -758,7 +758,7 @@ bool Ledger::saveValidatedLedger (bool current) << " affects no accounts"; db->executeSQL ( - SerializedTransaction::getMetaSQLInsertReplaceHeader () + + STTx::getMetaSQLInsertReplaceHeader () + vt.second->getTxn ()->getMetaSQL ( getLedgerSeq (), vt.second->getEscMeta ()) + ";"); } @@ -1196,7 +1196,7 @@ Json::Value Ledger::getJson (int options) const if (type == SHAMapTreeNode::tnTRANSACTION_NM) { SerializerIterator sit (item->peekSerializer ()); - SerializedTransaction txn (sit); + STTx txn (sit); txns.append (txn.getJson (0)); } else if (type == SHAMapTreeNode::tnTRANSACTION_MD) @@ -1205,7 +1205,7 @@ Json::Value Ledger::getJson (int options) const Serializer sTxn (sit.getVL ()); SerializerIterator tsit (sTxn); - SerializedTransaction txn (tsit); + STTx txn (tsit); TransactionMetaSet meta ( item->getTag (), mLedgerSeq, sit.getVL ()); diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h index a2485a1a4b..9c4e1f6f0f 100644 --- a/src/ripple/app/ledger/Ledger.h +++ b/src/ripple/app/ledger/Ledger.h @@ -24,10 +24,11 @@ #include #include #include -#include +#include #include #include #include +#include namespace ripple { @@ -274,9 +275,9 @@ public: uint256 const& transID, TransactionMetaSet::pointer & txMeta) const; bool getMetaHex (uint256 const& transID, std::string & hex) const; - static SerializedTransaction::pointer getSTransaction ( + static STTx::pointer getSTransaction ( SHAMapItem::ref, SHAMapTreeNode::TNType); - SerializedTransaction::pointer getSMTransaction ( + STTx::pointer getSMTransaction ( SHAMapItem::ref, SHAMapTreeNode::TNType, TransactionMetaSet::pointer & txMeta) const; diff --git a/src/ripple/app/ledger/LedgerCleaner.cpp b/src/ripple/app/ledger/LedgerCleaner.cpp index 31b98380dd..fbd516589c 100644 --- a/src/ripple/app/ledger/LedgerCleaner.cpp +++ b/src/ripple/app/ledger/LedgerCleaner.cpp @@ -17,7 +17,9 @@ */ //============================================================================== +#include #include +#include #include // namespace ripple { diff --git a/src/ripple/app/ledger/LedgerEntrySet.cpp b/src/ripple/app/ledger/LedgerEntrySet.cpp index 9312c00d46..f0f5e761d6 100644 --- a/src/ripple/app/ledger/LedgerEntrySet.cpp +++ b/src/ripple/app/ledger/LedgerEntrySet.cpp @@ -75,7 +75,7 @@ SLE::pointer LedgerEntrySet::getEntry (uint256 const& index, LedgerEntryAction& if (it->second.mSeq != mSeq) { assert (it->second.mSeq < mSeq); - it->second.mEntry = std::make_shared (*it->second.mEntry); + it->second.mEntry = std::make_shared (*it->second.mEntry); it->second.mSeq = mSeq; } @@ -357,7 +357,7 @@ SLE::pointer LedgerEntrySet::getForMod (uint256 const& node, Ledger::ref ledger, if (it->second.mSeq != mSeq) { - it->second.mEntry = std::make_shared (*it->second.mEntry); + it->second.mEntry = std::make_shared (*it->second.mEntry); it->second.mSeq = mSeq; } diff --git a/src/ripple/app/ledger/LedgerHistory.h b/src/ripple/app/ledger/LedgerHistory.h index 522859855a..1d72b8c1e2 100644 --- a/src/ripple/app/ledger/LedgerHistory.h +++ b/src/ripple/app/ledger/LedgerHistory.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_LEDGERHISTORY_H #define RIPPLE_LEDGERHISTORY_H +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/LedgerMaster.cpp b/src/ripple/app/ledger/LedgerMaster.cpp index 2ef2a5c191..cf5fbc4c5c 100644 --- a/src/ripple/app/ledger/LedgerMaster.cpp +++ b/src/ripple/app/ledger/LedgerMaster.cpp @@ -19,6 +19,10 @@ #include #include +#include +#include +#include +#include #include #include #include @@ -355,7 +359,7 @@ public: mBuildingLedgerSeq.store (i); } - TER doTransaction (SerializedTransaction::ref txn, TransactionEngineParams params, bool& didApply) + TER doTransaction (STTx::ref txn, TransactionEngineParams params, bool& didApply) { Ledger::pointer ledger; TransactionEngine engine; diff --git a/src/ripple/app/ledger/LedgerMaster.h b/src/ripple/app/ledger/LedgerMaster.h index d7e9c212fc..455a30c95e 100644 --- a/src/ripple/app/ledger/LedgerMaster.h +++ b/src/ripple/app/ledger/LedgerMaster.h @@ -21,6 +21,7 @@ #define RIPPLE_LEDGERMASTER_H_INCLUDED #include +#include #include #include #include @@ -72,7 +73,7 @@ public: virtual bool isCaughtUp(std::string& reason) = 0; virtual TER doTransaction ( - SerializedTransaction::ref txn, + STTx::ref txn, TransactionEngineParams params, bool& didApply) = 0; virtual int getMinValidations () = 0; diff --git a/src/ripple/app/ledger/OrderBookDB.h b/src/ripple/app/ledger/OrderBookDB.h index b6c938ccf1..936c5e5e6f 100644 --- a/src/ripple/app/ledger/OrderBookDB.h +++ b/src/ripple/app/ledger/OrderBookDB.h @@ -20,7 +20,9 @@ #ifndef RIPPLE_ORDERBOOKDB_H_INCLUDED #define RIPPLE_ORDERBOOKDB_H_INCLUDED +#include #include +#include namespace ripple { diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 47f252575f..ed237ccdf6 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -1075,7 +1075,7 @@ bool ApplicationImp::loadOldLedger ( if (stp.object && (uIndex.isNonZero())) { - SerializedLedgerEntry sle (*stp.object, uIndex); + STLedgerEntry sle (*stp.object, uIndex); bool ok = loadLedger->addSLE (sle); if (!ok) m_journal.warning << "Couldn't add serialized ledger: " << uIndex; diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h index fbbef68cbb..f2614e4076 100644 --- a/src/ripple/app/main/Application.h +++ b/src/ripple/app/main/Application.h @@ -53,14 +53,14 @@ class OrderBookDB; class Overlay; class PathRequests; class ProofOfWorkFactory; -class SerializedLedgerEntry; +class STLedgerEntry; class TransactionMaster; class Validations; class DatabaseCon; using NodeCache = TaggedCache ; -using SLECache = TaggedCache ; +using SLECache = TaggedCache ; class Application : public beast::PropertyStream::Source { diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index 06e8e56c3b..ecf8d194fe 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #if defined(BEAST_LINUX) || defined(BEAST_MAC) || defined(BEAST_BSD) #include diff --git a/src/ripple/app/misc/AccountState.cpp b/src/ripple/app/misc/AccountState.cpp index 82db79e6ef..45d3bbe782 100644 --- a/src/ripple/app/misc/AccountState.cpp +++ b/src/ripple/app/misc/AccountState.cpp @@ -30,7 +30,7 @@ AccountState::AccountState (RippleAddress const& naAccountID) { mValid = true; - mLedgerEntry = std::make_shared ( + mLedgerEntry = std::make_shared ( ltACCOUNT_ROOT, getAccountRootIndex (naAccountID)); mLedgerEntry->setFieldAccount (sfAccount, naAccountID.getAccountID ()); diff --git a/src/ripple/app/misc/AccountState.h b/src/ripple/app/misc/AccountState.h index cbd38140e3..2506c6691b 100644 --- a/src/ripple/app/misc/AccountState.h +++ b/src/ripple/app/misc/AccountState.h @@ -58,17 +58,17 @@ public: return mLedgerEntry->getFieldU32 (sfSequence); } - SerializedLedgerEntry::pointer getSLE () + STLedgerEntry::pointer getSLE () { return mLedgerEntry; } - SerializedLedgerEntry const& peekSLE () const + STLedgerEntry const& peekSLE () const { return *mLedgerEntry; } - SerializedLedgerEntry& peekSLE () + STLedgerEntry& peekSLE () { return *mLedgerEntry; } @@ -84,7 +84,7 @@ public: private: RippleAddress const mAccountID; RippleAddress mAuthorizedKey; - SerializedLedgerEntry::pointer mLedgerEntry; + STLedgerEntry::pointer mLedgerEntry; bool mValid; }; diff --git a/src/ripple/app/misc/AmendmentTableImpl.cpp b/src/ripple/app/misc/AmendmentTableImpl.cpp index fef0a684af..8cb7b34361 100644 --- a/src/ripple/app/misc/AmendmentTableImpl.cpp +++ b/src/ripple/app/misc/AmendmentTableImpl.cpp @@ -473,7 +473,7 @@ AmendmentTableImpl::doVoting (Ledger::ref lastClosedLedger, "Voting for amendment: " << uAmendment; // Create the transaction to enable the amendment - SerializedTransaction trans (ttAMENDMENT); + STTx trans (ttAMENDMENT); trans.setFieldAccount (sfAccount, Account ()); trans.setFieldH256 (sfAmendment, uAmendment); uint256 txID = trans.getTransactionID (); diff --git a/src/ripple/app/misc/CanonicalTXSet.cpp b/src/ripple/app/misc/CanonicalTXSet.cpp index 637e435967..f2be1614a8 100644 --- a/src/ripple/app/misc/CanonicalTXSet.cpp +++ b/src/ripple/app/misc/CanonicalTXSet.cpp @@ -71,7 +71,7 @@ bool CanonicalTXSet::Key::operator>= (Key const& rhs)const return mTXid >= rhs.mTXid; } -void CanonicalTXSet::push_back (SerializedTransaction::ref txn) +void CanonicalTXSet::push_back (STTx::ref txn) { uint256 effectiveAccount = mSetHash; diff --git a/src/ripple/app/misc/CanonicalTXSet.h b/src/ripple/app/misc/CanonicalTXSet.h index a9ac7851ce..69edb74684 100644 --- a/src/ripple/app/misc/CanonicalTXSet.h +++ b/src/ripple/app/misc/CanonicalTXSet.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_CANONICALTXSET_H #define RIPPLE_CANONICALTXSET_H +#include + namespace ripple { /** Holds transactions which were deferred to the next pass of consensus. @@ -68,8 +70,8 @@ public: std::uint32_t mSeq; }; - typedef std::map ::iterator iterator; - typedef std::map ::const_iterator const_iterator; + typedef std::map ::iterator iterator; + typedef std::map ::const_iterator const_iterator; public: explicit CanonicalTXSet (LedgerHash const& lastClosedLedgerHash) @@ -77,7 +79,7 @@ public: { } - void push_back (SerializedTransaction::ref txn); + void push_back (STTx::ref txn); // VFALCO TODO remove this function void reset (LedgerHash const& newLastClosedLedgerHash) @@ -118,7 +120,7 @@ private: // Used to salt the accounts so people can't mine for low account numbers uint256 mSetHash; - std::map mMap; + std::map mMap; }; } // ripple diff --git a/src/ripple/app/misc/FeeVoteImpl.cpp b/src/ripple/app/misc/FeeVoteImpl.cpp index 00202cdfe3..b59f3c5d7a 100644 --- a/src/ripple/app/misc/FeeVoteImpl.cpp +++ b/src/ripple/app/misc/FeeVoteImpl.cpp @@ -158,7 +158,7 @@ FeeVoteImpl::doVoting (Ledger::ref lastClosedLedger, lastClosedLedger->getParentHash ()); for (auto const& e : set) { - SerializedValidation const& val = *e.second; + STValidation const& val = *e.second; if (val.isTrusted ()) { @@ -206,7 +206,7 @@ FeeVoteImpl::doVoting (Ledger::ref lastClosedLedger, "/" << baseReserve << "/" << incReserve; - SerializedTransaction trans (ttFEE); + STTx trans (ttFEE); trans.setFieldAccount (sfAccount, Account ()); trans.setFieldU64 (sfBaseFee, baseFee); trans.setFieldU32 (sfReferenceFeeUnits, 10); diff --git a/src/ripple/app/misc/IHashRouter.h b/src/ripple/app/misc/IHashRouter.h index 7a9cecbb8b..70c098f9a9 100644 --- a/src/ripple/app/misc/IHashRouter.h +++ b/src/ripple/app/misc/IHashRouter.h @@ -20,6 +20,9 @@ #ifndef RIPPLE_HASHROUTER_H_INCLUDED #define RIPPLE_HASHROUTER_H_INCLUDED +#include +#include + namespace ripple { // VFALCO NOTE Are these the flags?? Why aren't we using a packed struct? diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index ae90fe45c3..c746b3f70e 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -161,11 +161,11 @@ public: return m_ledgerMaster.getFullValidatedRange (minVal, maxVal); } - SerializedValidation::ref getLastValidation () + STValidation::ref getLastValidation () { return mLastValidation; } - void setLastValidation (SerializedValidation::ref v) + void setLastValidation (STValidation::ref v) { mLastValidation = v; } @@ -186,7 +186,7 @@ public: // must complete immediately typedef std::function stCallback; void submitTransaction ( - Job&, SerializedTransaction::pointer, + Job&, STTx::pointer, stCallback callback = stCallback ()); Transaction::pointer submitTransactionSync ( @@ -266,7 +266,7 @@ public: const std::list< Blob >& nodeData); bool recvValidation ( - SerializedValidation::ref val, std::string const& source); + STValidation::ref val, std::string const& source); void takePosition (int seq, SHAMap::ref position); SHAMap::pointer getTXMap (uint256 const& hash); bool hasTXSet ( @@ -382,7 +382,7 @@ public: m_localTX->sweep (newValidLedger); } void addLocalTx ( - Ledger::ref openLedger, SerializedTransaction::ref txn) override + Ledger::ref openLedger, STTx::ref txn) override { m_localTX->push_back (openLedger->getLedgerSeq(), txn); } @@ -433,7 +433,7 @@ public: // void pubLedger (Ledger::ref lpAccepted); void pubProposedTransaction ( - Ledger::ref lpCurrent, SerializedTransaction::ref stTxn, TER terResult); + Ledger::ref lpCurrent, STTx::ref stTxn, TER terResult); //-------------------------------------------------------------------------- // @@ -488,7 +488,7 @@ private: void setMode (OperatingMode); Json::Value transJson ( - const SerializedTransaction& stTxn, TER terResult, bool bValidated, + const STTx& stTxn, TER terResult, bool bValidated, Ledger::ref lpCurrent); bool haveConsensusObject (); @@ -549,7 +549,7 @@ private: std::uint32_t mLastCloseTime; std::uint32_t mLastValidationTime; - SerializedValidation::pointer mLastValidation; + STValidation::pointer mLastValidation; // Recent positions taken std::map > mRecentPositions; @@ -834,14 +834,14 @@ bool NetworkOPsImp::isValidated (std::uint32_t seq) } void NetworkOPsImp::submitTransaction ( - Job&, SerializedTransaction::pointer iTrans, stCallback callback) + Job&, STTx::pointer iTrans, stCallback callback) { // this is an asynchronous interface Serializer s; iTrans->add (s); SerializerIterator sit (s); - auto trans = std::make_shared (std::ref (sit)); + auto trans = std::make_shared (std::ref (sit)); uint256 suppress = trans->getTransactionID (); int flags; @@ -2235,7 +2235,7 @@ NetworkOPsImp::getLedgerAffectedAccounts (std::uint32_t ledgerSeq) } bool NetworkOPsImp::recvValidation ( - SerializedValidation::ref val, std::string const& source) + STValidation::ref val, std::string const& source) { m_journal.debug << "recvValidation " << val->getLedgerHash () << " from " << source; @@ -2449,7 +2449,7 @@ Json::Value NetworkOPsImp::pubBootstrapAccountInfo ( } void NetworkOPsImp::pubProposedTransaction ( - Ledger::ref lpCurrent, SerializedTransaction::ref stTxn, TER terResult) + Ledger::ref lpCurrent, STTx::ref stTxn, TER terResult) { Json::Value jvObj = transJson (*stTxn, terResult, false, lpCurrent); @@ -2549,7 +2549,7 @@ void NetworkOPsImp::reportFeeChange () // This routine should only be used to publish accepted or validated // transactions. Json::Value NetworkOPsImp::transJson( - const SerializedTransaction& stTxn, TER terResult, bool bValidated, + const STTx& stTxn, TER terResult, bool bValidated, Ledger::ref lpCurrent) { Json::Value jvObj (Json::objectValue); diff --git a/src/ripple/app/misc/NetworkOPs.h b/src/ripple/app/misc/NetworkOPs.h index 9c422bc5bb..2770f2b68c 100644 --- a/src/ripple/app/misc/NetworkOPs.h +++ b/src/ripple/app/misc/NetworkOPs.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_NETWORKOPS_H #define RIPPLE_NETWORKOPS_H -#include +#include #include #include // #include @@ -128,8 +128,8 @@ public: virtual bool getValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) = 0; virtual bool getFullValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) = 0; - virtual SerializedValidation::ref getLastValidation () = 0; - virtual void setLastValidation (SerializedValidation::ref v) = 0; + virtual STValidation::ref getLastValidation () = 0; + virtual void setLastValidation (STValidation::ref v) = 0; virtual SLE::pointer getSLE (Ledger::pointer lpLedger, uint256 const& uHash) = 0; virtual SLE::pointer getSLEi (Ledger::pointer lpLedger, uint256 const& uHash) = 0; @@ -141,7 +141,7 @@ public: // must complete immediately // VFALCO TODO Make this a TxCallback structure typedef std::function stCallback; - virtual void submitTransaction (Job&, SerializedTransaction::pointer, + virtual void submitTransaction (Job&, STTx::pointer, stCallback callback = stCallback ()) = 0; virtual Transaction::pointer submitTransactionSync (Transaction::ref tpTrans, bool bAdmin, bool bLocal, bool bFailHard, bool bSubmit) = 0; @@ -207,7 +207,7 @@ public: uint256 const& hash, const std::list& nodeIDs, const std::list< Blob >& nodeData) = 0; - virtual bool recvValidation (SerializedValidation::ref val, + virtual bool recvValidation (STValidation::ref val, std::string const& source) = 0; virtual void takePosition (int seq, SHAMap::ref position) = 0; @@ -274,7 +274,7 @@ public: virtual void reportFeeChange () = 0; virtual void updateLocalTx (Ledger::ref newValidLedger) = 0; - virtual void addLocalTx (Ledger::ref openLedger, SerializedTransaction::ref txn) = 0; + virtual void addLocalTx (Ledger::ref openLedger, STTx::ref txn) = 0; virtual std::size_t getLocalTxCount () = 0; //Helper function to generate SQL query to get transactions @@ -321,7 +321,7 @@ public: // virtual void pubLedger (Ledger::ref lpAccepted) = 0; virtual void pubProposedTransaction (Ledger::ref lpCurrent, - SerializedTransaction::ref stTxn, TER terResult) = 0; + STTx::ref stTxn, TER terResult) = 0; }; std::unique_ptr diff --git a/src/ripple/app/misc/Validations.cpp b/src/ripple/app/misc/Validations.cpp index 9792a8bc6e..f26da6bcef 100644 --- a/src/ripple/app/misc/Validations.cpp +++ b/src/ripple/app/misc/Validations.cpp @@ -69,7 +69,7 @@ public: } private: - bool addValidation (SerializedValidation::ref val, std::string const& source) + bool addValidation (STValidation::ref val, std::string const& source) { RippleAddress signer = val->getSignerPublic (); bool isCurrent = false; @@ -293,11 +293,11 @@ private: return (goodNodes * 100) / (goodNodes + badNodes); } - std::list getCurrentTrustedValidations () + std::list getCurrentTrustedValidations () { std::uint32_t cutoff = getApp().getOPs ().getNetworkTimeNC () - LEDGER_VAL_INTERVAL; - std::list ret; + std::list ret; ScopedLockType sl (mLock); auto it = mCurrentValidations.begin (); diff --git a/src/ripple/app/misc/Validations.h b/src/ripple/app/misc/Validations.h index 2eff884760..e04a839c60 100644 --- a/src/ripple/app/misc/Validations.h +++ b/src/ripple/app/misc/Validations.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_VALIDATIONS_H_INCLUDED #define RIPPLE_VALIDATIONS_H_INCLUDED +#include #include // namespace ripple { @@ -27,11 +28,11 @@ namespace ripple { // VFALCO TODO rename and move these typedefs into the Validations interface // nodes validating and highest node ID validating -typedef hash_map ValidationSet; +typedef hash_map ValidationSet; typedef std::pair ValidationCounter; typedef hash_map LedgerToValidationCounter; -typedef std::vector ValidationVector; +typedef std::vector ValidationVector; class Validations : beast::LeakChecked { @@ -39,7 +40,7 @@ public: virtual ~Validations () { } - virtual bool addValidation (SerializedValidation::ref, std::string const& source) = 0; + virtual bool addValidation (STValidation::ref, std::string const& source) = 0; virtual ValidationSet getValidations (uint256 const& ledger) = 0; @@ -63,7 +64,7 @@ public: virtual LedgerToValidationCounter getCurrentValidations ( uint256 currentLedger, uint256 previousLedger) = 0; - virtual std::list + virtual std::list getCurrentTrustedValidations () = 0; virtual void tune (int size, int age) = 0; diff --git a/src/ripple/app/paths/Node.h b/src/ripple/app/paths/Node.h index 22b139b8ee..94dc91b5c2 100644 --- a/src/ripple/app/paths/Node.h +++ b/src/ripple/app/paths/Node.h @@ -22,7 +22,7 @@ #include #include -#include +#include namespace ripple { namespace path { diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/ripple/app/paths/PathRequest.cpp index 66671dcb90..8227550b67 100644 --- a/src/ripple/app/paths/PathRequest.cpp +++ b/src/ripple/app/paths/PathRequest.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/ripple/app/paths/PathRequest.h b/src/ripple/app/paths/PathRequest.h index 9b68199683..e33fdc4dfa 100644 --- a/src/ripple/app/paths/PathRequest.h +++ b/src/ripple/app/paths/PathRequest.h @@ -20,6 +20,9 @@ #ifndef RIPPLE_PATHREQUEST_H #define RIPPLE_PATHREQUEST_H +#include +#include + namespace ripple { // A pathfinding request submitted by a client diff --git a/src/ripple/app/paths/PathRequests.h b/src/ripple/app/paths/PathRequests.h index dc88fb150d..5731abd982 100644 --- a/src/ripple/app/paths/PathRequests.h +++ b/src/ripple/app/paths/PathRequests.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_PATHREQUESTS_H #define RIPPLE_PATHREQUESTS_H +#include +#include #include #include diff --git a/src/ripple/app/paths/RippleLineCache.h b/src/ripple/app/paths/RippleLineCache.h index 6d341ee3df..5c5248f0a9 100644 --- a/src/ripple/app/paths/RippleLineCache.h +++ b/src/ripple/app/paths/RippleLineCache.h @@ -20,6 +20,11 @@ #ifndef RIPPLE_RIPPLELINECACHE_H #define RIPPLE_RIPPLELINECACHE_H +#include +#include +#include +#include + namespace ripple { // Used by Pathfinder diff --git a/src/ripple/app/paths/RippleState.cpp b/src/ripple/app/paths/RippleState.cpp index fdb0ae9f46..7669a9b952 100644 --- a/src/ripple/app/paths/RippleState.cpp +++ b/src/ripple/app/paths/RippleState.cpp @@ -20,7 +20,7 @@ namespace ripple { RippleState::pointer RippleState::makeItem ( - Account const& accountID, SerializedLedgerEntry::ref ledgerEntry) + Account const& accountID, STLedgerEntry::ref ledgerEntry) { if (!ledgerEntry || ledgerEntry->getType () != ltRIPPLE_STATE) return pointer (); @@ -29,7 +29,7 @@ RippleState::pointer RippleState::makeItem ( } RippleState::RippleState ( - SerializedLedgerEntry::ref ledgerEntry, + STLedgerEntry::ref ledgerEntry, Account const& viewAccount) : mLedgerEntry (ledgerEntry) , mLowLimit (ledgerEntry->getFieldAmount (sfLowLimit)) diff --git a/src/ripple/app/paths/RippleState.h b/src/ripple/app/paths/RippleState.h index 90001d2b61..b4d54c5eca 100644 --- a/src/ripple/app/paths/RippleState.h +++ b/src/ripple/app/paths/RippleState.h @@ -38,7 +38,7 @@ public: virtual ~RippleState () { } static RippleState::pointer makeItem ( - Account const& accountID, SerializedLedgerEntry::ref ledgerEntry); + Account const& accountID, STLedgerEntry::ref ledgerEntry); LedgerEntryType getType () { @@ -113,17 +113,17 @@ public: return ((std::uint32_t) (mViewLowest ? mLowQualityOut : mHighQualityOut)); } - SerializedLedgerEntry::pointer getSLE () + STLedgerEntry::pointer getSLE () { return mLedgerEntry; } - const SerializedLedgerEntry& peekSLE () const + const STLedgerEntry& peekSLE () const { return *mLedgerEntry; } - SerializedLedgerEntry& peekSLE () + STLedgerEntry& peekSLE () { return *mLedgerEntry; } @@ -134,11 +134,11 @@ public: private: RippleState ( - SerializedLedgerEntry::ref ledgerEntry, + STLedgerEntry::ref ledgerEntry, Account const& viewAccount); private: - SerializedLedgerEntry::pointer mLedgerEntry; + STLedgerEntry::pointer mLedgerEntry; bool mViewLowest; diff --git a/src/ripple/app/shamap/SHAMapSyncFilters.cpp b/src/ripple/app/shamap/SHAMapSyncFilters.cpp index 161b016912..ee2e7ccbf6 100644 --- a/src/ripple/app/shamap/SHAMapSyncFilters.cpp +++ b/src/ripple/app/shamap/SHAMapSyncFilters.cpp @@ -17,7 +17,10 @@ */ //============================================================================== +#include +#include #include +#include namespace ripple { @@ -43,7 +46,7 @@ void ConsensusTransSetSF::gotNode (bool fromFilter, const SHAMapNodeID& id, uint { Serializer s (nodeData.begin () + 4, nodeData.end ()); // skip prefix SerializerIterator sit (s); - SerializedTransaction::pointer stx = std::make_shared (std::ref (sit)); + STTx::pointer stx = std::make_shared (std::ref (sit)); assert (stx->getTransactionID () == nodeHash); getApp().getJobQueue ().addJob ( jtTRANSACTION, "TXS->TXN", diff --git a/src/ripple/app/transactors/AddWallet.cpp b/src/ripple/app/transactors/AddWallet.cpp index 46422bf48c..8276983ef7 100644 --- a/src/ripple/app/transactors/AddWallet.cpp +++ b/src/ripple/app/transactors/AddWallet.cpp @@ -24,7 +24,7 @@ class AddWallet { public: AddWallet ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -118,7 +118,7 @@ public: TER transact_AddWallet ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/CancelOffer.cpp b/src/ripple/app/transactors/CancelOffer.cpp index da6dfd3ec7..56f7d0d0d1 100644 --- a/src/ripple/app/transactors/CancelOffer.cpp +++ b/src/ripple/app/transactors/CancelOffer.cpp @@ -24,7 +24,7 @@ class CancelOffer { public: CancelOffer ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -86,7 +86,7 @@ public: TER transact_CancelOffer ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/CancelTicket.cpp b/src/ripple/app/transactors/CancelTicket.cpp index 889890ae26..55889373fc 100644 --- a/src/ripple/app/transactors/CancelTicket.cpp +++ b/src/ripple/app/transactors/CancelTicket.cpp @@ -24,7 +24,7 @@ class CancelTicket { public: CancelTicket ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -81,7 +81,7 @@ public: TER transact_CancelTicket ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/Change.cpp b/src/ripple/app/transactors/Change.cpp index 2fc210a8ad..7d04e57df1 100644 --- a/src/ripple/app/transactors/Change.cpp +++ b/src/ripple/app/transactors/Change.cpp @@ -26,7 +26,7 @@ class Change { public: Change ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -178,7 +178,7 @@ private: TER transact_Change ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/CreateOffer.cpp b/src/ripple/app/transactors/CreateOffer.cpp index a770b880dc..5c15e55499 100644 --- a/src/ripple/app/transactors/CreateOffer.cpp +++ b/src/ripple/app/transactors/CreateOffer.cpp @@ -126,7 +126,7 @@ private: public: CreateOffer ( bool autobridging, - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -582,7 +582,7 @@ public: TER transact_CreateOffer ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/CreateTicket.cpp b/src/ripple/app/transactors/CreateTicket.cpp index bd2935f696..30d61580e2 100644 --- a/src/ripple/app/transactors/CreateTicket.cpp +++ b/src/ripple/app/transactors/CreateTicket.cpp @@ -24,7 +24,7 @@ class CreateTicket { public: CreateTicket ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -123,7 +123,7 @@ public: TER transact_CreateTicket ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/Payment.cpp b/src/ripple/app/transactors/Payment.cpp index f6f22f80e1..9e7dd6fdd2 100644 --- a/src/ripple/app/transactors/Payment.cpp +++ b/src/ripple/app/transactors/Payment.cpp @@ -32,7 +32,7 @@ class Payment public: Payment ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -372,7 +372,7 @@ public: TER transact_Payment ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/SetAccount.cpp b/src/ripple/app/transactors/SetAccount.cpp index f2f0e237f8..5c9c27d1ac 100644 --- a/src/ripple/app/transactors/SetAccount.cpp +++ b/src/ripple/app/transactors/SetAccount.cpp @@ -29,7 +29,7 @@ class SetAccount public: SetAccount ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -338,7 +338,7 @@ public: TER transact_SetAccount ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/SetRegularKey.cpp b/src/ripple/app/transactors/SetRegularKey.cpp index ab4f87e054..97a98d5360 100644 --- a/src/ripple/app/transactors/SetRegularKey.cpp +++ b/src/ripple/app/transactors/SetRegularKey.cpp @@ -37,7 +37,7 @@ class SetRegularKey public: SetRegularKey ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -84,7 +84,7 @@ public: TER transact_SetRegularKey ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/SetTrust.cpp b/src/ripple/app/transactors/SetTrust.cpp index ba5d3adaef..cdc499c931 100644 --- a/src/ripple/app/transactors/SetTrust.cpp +++ b/src/ripple/app/transactors/SetTrust.cpp @@ -24,7 +24,7 @@ class SetTrust { public: SetTrust ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) : Transactor ( @@ -421,7 +421,7 @@ public: TER transact_SetTrust ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { diff --git a/src/ripple/app/transactors/Transactor.cpp b/src/ripple/app/transactors/Transactor.cpp index a568d91cad..63330f786c 100644 --- a/src/ripple/app/transactors/Transactor.cpp +++ b/src/ripple/app/transactors/Transactor.cpp @@ -22,20 +22,20 @@ namespace ripple { -TER transact_Payment (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_SetAccount (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_SetRegularKey (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_SetTrust (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_CreateOffer (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_CancelOffer (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_AddWallet (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_Change (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_CreateTicket (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); -TER transact_CancelTicket (SerializedTransaction const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_Payment (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_SetAccount (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_SetRegularKey (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_SetTrust (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_CreateOffer (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_CancelOffer (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_AddWallet (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_Change (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_CreateTicket (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); +TER transact_CancelTicket (STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); TER Transactor::transact ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine) { @@ -78,7 +78,7 @@ Transactor::transact ( } Transactor::Transactor ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine, beast::Journal journal) diff --git a/src/ripple/app/transactors/Transactor.h b/src/ripple/app/transactors/Transactor.h index 6dcbc901cc..826490646e 100644 --- a/src/ripple/app/transactors/Transactor.h +++ b/src/ripple/app/transactors/Transactor.h @@ -28,7 +28,7 @@ public: static TER transact ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, TransactionEngine* engine); @@ -36,7 +36,7 @@ public: apply (); protected: - SerializedTransaction const& mTxn; + STTx const& mTxn; TransactionEngine* mEngine; TransactionEngineParams mParams; @@ -64,7 +64,7 @@ protected: virtual TER doApply () = 0; Transactor ( - const SerializedTransaction& txn, + const STTx& txn, TransactionEngineParams params, TransactionEngine* engine, beast::Journal journal = beast::Journal ()); diff --git a/src/ripple/app/tx/LocalTxs.cpp b/src/ripple/app/tx/LocalTxs.cpp index a7c1557db1..85b1371b89 100644 --- a/src/ripple/app/tx/LocalTxs.cpp +++ b/src/ripple/app/tx/LocalTxs.cpp @@ -55,7 +55,7 @@ public: // get into a fully-validated ledger. static int const holdLedgers = 5; - LocalTx (LedgerIndex index, SerializedTransaction::ref txn) + LocalTx (LedgerIndex index, STTx::ref txn) : m_txn (txn) , m_expire (index + holdLedgers) , m_id (txn->getTransactionID ()) @@ -81,7 +81,7 @@ public: return i > m_expire; } - SerializedTransaction::ref getTX () const + STTx::ref getTX () const { return m_txn; } @@ -93,7 +93,7 @@ public: private: - SerializedTransaction::pointer m_txn; + STTx::pointer m_txn; LedgerIndex m_expire; uint256 m_id; RippleAddress m_account; @@ -108,7 +108,7 @@ public: { } // Add a new transaction to the set of local transactions - void push_back (LedgerIndex index, SerializedTransaction::ref txn) override + void push_back (LedgerIndex index, STTx::ref txn) override { std::lock_guard lock (m_lock); diff --git a/src/ripple/app/tx/LocalTxs.h b/src/ripple/app/tx/LocalTxs.h index c68e6f6da0..09eedf66da 100644 --- a/src/ripple/app/tx/LocalTxs.h +++ b/src/ripple/app/tx/LocalTxs.h @@ -20,6 +20,9 @@ #ifndef RIPPLE_LOCALTRANSACTIONS_H #define RIPPLE_LOCALTRANSACTIONS_H +#include +#include + namespace ripple { // Track transactions issued by local clients @@ -35,7 +38,7 @@ public: static std::unique_ptr New (); // Add a new local transaction - virtual void push_back (LedgerIndex index, SerializedTransaction::ref txn) = 0; + virtual void push_back (LedgerIndex index, STTx::ref txn) = 0; // Apply local transactions to a new open ledger virtual void apply (TransactionEngine&) = 0; diff --git a/src/ripple/app/tx/Transaction.cpp b/src/ripple/app/tx/Transaction.cpp index 1e8ec31f9e..0ba88e4bef 100644 --- a/src/ripple/app/tx/Transaction.cpp +++ b/src/ripple/app/tx/Transaction.cpp @@ -19,7 +19,7 @@ namespace ripple { -Transaction::Transaction (SerializedTransaction::ref sit, Validate validate) +Transaction::Transaction (STTx::ref sit, Validate validate) : mInLedger (0), mStatus (INVALID), mResult (temUNCERTAIN), @@ -52,7 +52,7 @@ Transaction::pointer Transaction::sharedTransaction ( SerializerIterator sit (s); return std::make_shared ( - std::make_shared (sit), + std::make_shared (sit), validate); } catch (...) @@ -105,7 +105,7 @@ Transaction::pointer Transaction::transactionFromSQL ( rawTxn.resize (txSize); SerializerIterator it (rawTxn); - auto txn = std::make_shared (it); + auto txn = std::make_shared (it); auto tr = std::make_shared (txn, validate); TransStatus st (INVALID); @@ -177,7 +177,7 @@ Transaction::pointer Transaction::transactionFromSQL (std::string const& sql) rawTxn.resize (txSize); SerializerIterator it (rawTxn); - auto txn = std::make_shared (it); + auto txn = std::make_shared (it); auto tr = std::make_shared (txn, Validate::YES); TransStatus st (INVALID); diff --git a/src/ripple/app/tx/Transaction.h b/src/ripple/app/tx/Transaction.h index 6024c2f0dd..12ba4ff4d8 100644 --- a/src/ripple/app/tx/Transaction.h +++ b/src/ripple/app/tx/Transaction.h @@ -20,7 +20,8 @@ #ifndef RIPPLE_TRANSACTION_H #define RIPPLE_TRANSACTION_H -#include +#include +#include #include namespace ripple { @@ -60,14 +61,14 @@ public: typedef const pointer& ref; public: - Transaction (SerializedTransaction::ref, Validate); + Transaction (STTx::ref, Validate); static Transaction::pointer sharedTransaction (Blob const&, Validate); static Transaction::pointer transactionFromSQL (Database*, Validate); bool checkSign () const; - SerializedTransaction::ref getSTransaction () + STTx::ref getSTransaction () { return mTransaction; } @@ -128,7 +129,7 @@ private: TransStatus mStatus; TER mResult; - SerializedTransaction::pointer mTransaction; + STTx::pointer mTransaction; }; } // ripple diff --git a/src/ripple/app/tx/TransactionAcquire.h b/src/ripple/app/tx/TransactionAcquire.h index 3a015587e5..8b4caa6fec 100644 --- a/src/ripple/app/tx/TransactionAcquire.h +++ b/src/ripple/app/tx/TransactionAcquire.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_TRANSACTIONACQUIRE_H #define RIPPLE_TRANSACTIONACQUIRE_H +#include + namespace ripple { // VFALCO TODO rename to PeerTxRequest diff --git a/src/ripple/app/tx/TransactionCheck.cpp b/src/ripple/app/tx/TransactionCheck.cpp index 5de9baf1bf..494021c576 100644 --- a/src/ripple/app/tx/TransactionCheck.cpp +++ b/src/ripple/app/tx/TransactionCheck.cpp @@ -23,7 +23,7 @@ namespace ripple { // Double check a transaction's metadata to make sure no system invariants were broken -bool TransactionEngine::checkInvariants (TER result, const SerializedTransaction& txn, TransactionEngineParams params) +bool TransactionEngine::checkInvariants (TER result, const STTx& txn, TransactionEngineParams params) { // VFALCO I deleted a bunch of code that was wrapped in #if 0. // If you need it, check the commit log. diff --git a/src/ripple/app/tx/TransactionEngine.cpp b/src/ripple/app/tx/TransactionEngine.cpp index ba1b6f129b..b76b91fc4d 100644 --- a/src/ripple/app/tx/TransactionEngine.cpp +++ b/src/ripple/app/tx/TransactionEngine.cpp @@ -71,7 +71,7 @@ void TransactionEngine::txnWrite () } TER TransactionEngine::applyTransaction ( - SerializedTransaction const& txn, + STTx const& txn, TransactionEngineParams params, bool& didApply) { @@ -86,7 +86,7 @@ TER TransactionEngine::applyTransaction ( Serializer ser; txn.add (ser); SerializerIterator sit (ser); - SerializedTransaction s2 (sit); + STTx s2 (sit); if (!s2.isEquivalent (txn)) { diff --git a/src/ripple/app/tx/TransactionEngine.h b/src/ripple/app/tx/TransactionEngine.h index 513536fec0..94c54b8c0b 100644 --- a/src/ripple/app/tx/TransactionEngine.h +++ b/src/ripple/app/tx/TransactionEngine.h @@ -17,8 +17,11 @@ */ //============================================================================== -#ifndef __TRANSACTIONENGINE__ -#define __TRANSACTIONENGINE__ +#ifndef RIPPLE_APP_TRANSACTIONENGINE_H_INCLUDED +#define RIPPLE_APP_TRANSACTIONENGINE_H_INCLUDED + +#include +#include namespace ripple { @@ -36,8 +39,8 @@ public: private: LedgerEntrySet mNodes; - TER setAuthorized (const SerializedTransaction & txn, bool bMustSetGenerator); - TER checkSig (const SerializedTransaction & txn); + TER setAuthorized (const STTx & txn, bool bMustSetGenerator); + TER checkSig (const STTx & txn); protected: Ledger::pointer mLedger; @@ -95,8 +98,8 @@ public: mNodes.entryModify (sleEntry); } - TER applyTransaction (const SerializedTransaction&, TransactionEngineParams, bool & didApply); - bool checkInvariants (TER result, const SerializedTransaction & txn, TransactionEngineParams params); + TER applyTransaction (const STTx&, TransactionEngineParams, bool & didApply); + bool checkInvariants (TER result, const STTx & txn, TransactionEngineParams params); }; inline TransactionEngineParams operator| (const TransactionEngineParams& l1, const TransactionEngineParams& l2) diff --git a/src/ripple/app/tx/TransactionMaster.cpp b/src/ripple/app/tx/TransactionMaster.cpp index 1e9cf24bad..5691dac35f 100644 --- a/src/ripple/app/tx/TransactionMaster.cpp +++ b/src/ripple/app/tx/TransactionMaster.cpp @@ -55,11 +55,11 @@ Transaction::pointer TransactionMaster::fetch (uint256 const& txnID, bool checkD return txn; } -SerializedTransaction::pointer TransactionMaster::fetch (SHAMapItem::ref item, +STTx::pointer TransactionMaster::fetch (SHAMapItem::ref item, SHAMapTreeNode::TNType type, bool checkDisk, std::uint32_t uCommitLedger) { - SerializedTransaction::pointer txn; + STTx::pointer txn; Transaction::pointer iTx = getApp().getMasterTransaction ().fetch (item->getTag (), false); if (!iTx) @@ -68,7 +68,7 @@ SerializedTransaction::pointer TransactionMaster::fetch (SHAMapItem::ref item, if (type == SHAMapTreeNode::tnTRANSACTION_NM) { SerializerIterator sit (item->peekSerializer ()); - txn = std::make_shared (std::ref (sit)); + txn = std::make_shared (std::ref (sit)); } else if (type == SHAMapTreeNode::tnTRANSACTION_MD) { @@ -77,7 +77,7 @@ SerializedTransaction::pointer TransactionMaster::fetch (SHAMapItem::ref item, item->peekSerializer ().getVL (s.modData (), 0, length); SerializerIterator sit (s); - txn = std::make_shared (std::ref (sit)); + txn = std::make_shared (std::ref (sit)); } } else diff --git a/src/ripple/app/tx/TransactionMaster.h b/src/ripple/app/tx/TransactionMaster.h index b99ab46efa..421685a522 100644 --- a/src/ripple/app/tx/TransactionMaster.h +++ b/src/ripple/app/tx/TransactionMaster.h @@ -30,7 +30,7 @@ public: TransactionMaster (); Transaction::pointer fetch (uint256 const& , bool checkDisk); - SerializedTransaction::pointer fetch (SHAMapItem::ref item, SHAMapTreeNode:: TNType type, + STTx::pointer fetch (SHAMapItem::ref item, SHAMapTreeNode:: TNType type, bool checkDisk, std::uint32_t uCommitLedger); // return value: true = we had the transaction already diff --git a/src/ripple/app/tx/TransactionMeta.cpp b/src/ripple/app/tx/TransactionMeta.cpp index 312ce964de..cb3b7b367a 100644 --- a/src/ripple/app/tx/TransactionMeta.cpp +++ b/src/ripple/app/tx/TransactionMeta.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include + namespace ripple { // VFALCO TODO rename class to TransactionMeta @@ -27,7 +29,7 @@ TransactionMetaSet::TransactionMetaSet (uint256 const& txid, std::uint32_t ledge Serializer s (vec); SerializerIterator sit (s); - std::unique_ptr pobj = STObject::deserialize (sit, sfMetadata); + std::unique_ptr pobj = STObject::deserialize (sit, sfMetadata); STObject* obj = static_cast (pobj.get ()); if (!obj) @@ -100,7 +102,7 @@ std::vector TransactionMetaSet::getAffectedAccounts () if (inner) { - BOOST_FOREACH (const SerializedType & field, inner->peekData ()) + BOOST_FOREACH (const STBase & field, inner->peekData ()) { const STAccount* sa = dynamic_cast (&field); diff --git a/src/ripple/app/tx/TransactionMeta.h b/src/ripple/app/tx/TransactionMeta.h index 985678be4f..fdb2dd833e 100644 --- a/src/ripple/app/tx/TransactionMeta.h +++ b/src/ripple/app/tx/TransactionMeta.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_TRANSACTIONMETA_H #define RIPPLE_TRANSACTIONMETA_H -#include +#include #include #include #include diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index a39c468ff2..2590993886 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -1318,8 +1318,8 @@ PeerImp::on_message (std::shared_ptr const& m) try { SerializerIterator sit (s); - SerializedTransaction::pointer stx = std::make_shared < - SerializedTransaction> (std::ref (sit)); + STTx::pointer stx = std::make_shared < + STTx> (std::ref (sit)); uint256 txID = stx->getTransactionID (); int flags; @@ -1658,8 +1658,8 @@ PeerImp::on_message (std::shared_ptr const& m) { Serializer s (m->validation ()); SerializerIterator sit (s); - SerializedValidation::pointer val = std::make_shared < - SerializedValidation> (std::ref (sit), false); + STValidation::pointer val = std::make_shared < + STValidation> (std::ref (sit), false); if (closeTime > (120 + val->getFieldU32(sfSigningTime))) { @@ -2477,7 +2477,7 @@ PeerImp::doProofOfWork (Job&, std::weak_ptr peer, void PeerImp::checkTransaction (Job&, int flags, - SerializedTransaction::pointer stx, std::weak_ptr peer) + STTx::pointer stx, std::weak_ptr peer) { // VFALCO TODO Rewrite to not use exceptions try @@ -2596,7 +2596,7 @@ PeerImp::checkPropose (Job& job, Overlay* pPeers, void PeerImp::checkValidation (Job&, Overlay* pPeers, - SerializedValidation::pointer val, bool isTrusted, bool isCluster, + STValidation::pointer val, bool isTrusted, bool isCluster, std::shared_ptr packet, std::weak_ptr peer, beast::Journal journal) { @@ -2624,7 +2624,7 @@ PeerImp::checkValidation (Job&, Overlay* pPeers, //---------------------------------------------------------------------- // { - SerializedValidation const& sv (*val); + STValidation const& sv (*val); Validators::ReceivedValidation rv; rv.ledgerHash = sv.getLedgerHash (); rv.publicKey = sv.getSignerPublic(); diff --git a/src/ripple/overlay/impl/PeerImp.h b/src/ripple/overlay/impl/PeerImp.h index 4400e463ba..a725360d87 100644 --- a/src/ripple/overlay/impl/PeerImp.h +++ b/src/ripple/overlay/impl/PeerImp.h @@ -531,7 +531,7 @@ private: doProofOfWork (Job&, std::weak_ptr peer, ProofOfWork::pointer pow); static - void checkTransaction (Job&, int flags, SerializedTransaction::pointer stx, + void checkTransaction (Job&, int flags, STTx::pointer stx, std::weak_ptr peer); // Called from our JobQueue @@ -545,7 +545,7 @@ private: static void - checkValidation (Job&, Overlay* pPeers, SerializedValidation::pointer val, + checkValidation (Job&, Overlay* pPeers, STValidation::pointer val, bool isTrusted, bool isCluster, std::shared_ptr packet, std::weak_ptr peer, beast::Journal journal); diff --git a/src/ripple/proto/ripple.proto b/src/ripple/proto/ripple.proto index e44833c0dd..69549b8c09 100644 --- a/src/ripple/proto/ripple.proto +++ b/src/ripple/proto/ripple.proto @@ -192,7 +192,7 @@ message TMHaveTransactionSet // Used to sign a final closed ledger after reprocessing message TMValidation { - required bytes validation = 1; // in SerializedValidation signed form + required bytes validation = 1; // in STValidation signed form optional bool checkedSignature = 2; // node vouches signature is correct } diff --git a/src/ripple/protocol/Indexes.h b/src/ripple/protocol/Indexes.h index e598560b4c..6082f9d817 100644 --- a/src/ripple/protocol/Indexes.h +++ b/src/ripple/protocol/Indexes.h @@ -23,10 +23,9 @@ #include #include #include - +#include #include #include -#include namespace ripple { diff --git a/src/ripple/protocol/KnownFormats.h b/src/ripple/protocol/KnownFormats.h index 46aca3db9f..cb27b002d0 100644 --- a/src/ripple/protocol/KnownFormats.h +++ b/src/ripple/protocol/KnownFormats.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_KNOWNFORMATS_H_INCLUDED #define RIPPLE_PROTOCOL_KNOWNFORMATS_H_INCLUDED -#include +#include #include // namespace ripple { diff --git a/src/ripple/protocol/README.md b/src/ripple/protocol/README.md index 241d370f98..32fc3375d9 100644 --- a/src/ripple/protocol/README.md +++ b/src/ripple/protocol/README.md @@ -2,3 +2,13 @@ Classes and functions for handling data and values associated with the Ripple protocol. + +## Serialized Objects + +In ripple objects transmitted over the network must be +serialized into a canonical format. The prefix "ST" refers +to classes that deal with the serialized format of ripple +objects. + +The term "Tx" or "tx" is an abbreviation for "Transaction", +a commonly occurring object type. diff --git a/src/ripple/protocol/RippleAddress.h b/src/ripple/protocol/RippleAddress.h index e691feefa8..86f0957edb 100644 --- a/src/ripple/protocol/RippleAddress.h +++ b/src/ripple/protocol/RippleAddress.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/protocol/SerializedObjectTemplate.h b/src/ripple/protocol/SOTemplate.h similarity index 90% rename from src/ripple/protocol/SerializedObjectTemplate.h rename to src/ripple/protocol/SOTemplate.h index 34fc02fe0d..cdf7af65b2 100644 --- a/src/ripple/protocol/SerializedObjectTemplate.h +++ b/src/ripple/protocol/SOTemplate.h @@ -17,16 +17,15 @@ */ //============================================================================== -#ifndef RIPPLE_PROTOCOL_SERIALIZEDOBJECTTEMPLATE_H_INCLUDED -#define RIPPLE_PROTOCOL_SERIALIZEDOBJECTTEMPLATE_H_INCLUDED +#ifndef RIPPLE_PROTOCOL_SOTEMPLATE_H_INCLUDED +#define RIPPLE_PROTOCOL_SOTEMPLATE_H_INCLUDED #include #include namespace ripple { -/** Flags for elements in a SerializedObjectTemplate. -*/ +/** Flags for elements in a SOTemplate. */ // VFALCO NOTE these don't look like bit-flags... enum SOE_Flags { @@ -38,8 +37,7 @@ enum SOE_Flags //------------------------------------------------------------------------------ -/** An element in a SerializedObjectTemplate. -*/ +/** An element in a SOTemplate. */ class SOElement { public: @@ -55,7 +53,7 @@ public: //------------------------------------------------------------------------------ -/** Defines the fields and their attributes within a SerializedObject. +/** Defines the fields and their attributes within a STObject. Each subclass of SerializedObject will provide its own template describing the available fields and their metadata attributes. */ diff --git a/src/ripple/protocol/STAccount.h b/src/ripple/protocol/STAccount.h new file mode 100644 index 0000000000..056c0c08c2 --- /dev/null +++ b/src/ripple/protocol/STAccount.h @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +/* + 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. +*/ +//============================================================================== + +#ifndef RIPPLE_PROTOCOL_STACCOUNT_H_INCLUDED +#define RIPPLE_PROTOCOL_STACCOUNT_H_INCLUDED + +#include + +namespace ripple { + +class STAccount : public STBlob +{ +public: + STAccount (Blob const& v) : STBlob (v) + { + ; + } + STAccount (SField::ref n, Blob const& v) : STBlob (n, v) + { + ; + } + STAccount (SField::ref n, Account const& v); + STAccount (SField::ref n) : STBlob (n) + { + ; + } + STAccount () + { + ; + } + static std::unique_ptr deserialize (SerializerIterator& sit, SField::ref name) + { + return std::unique_ptr (construct (sit, name)); + } + + SerializedTypeID getSType () const + { + return STI_ACCOUNT; + } + std::string getText () const; + + RippleAddress getValueNCA () const; + void setValueNCA (RippleAddress const& nca); + + template + void setValueH160 (base_uint<160, Tag> const& v) + { + peekValue ().clear (); + peekValue ().insert (peekValue ().end (), v.begin (), v.end ()); + assert (peekValue ().size () == (160 / 8)); + } + + template + bool getValueH160 (base_uint<160, Tag>& v) const + { + auto success = isValueH160 (); + if (success) + memcpy (v.begin (), & (peekValue ().front ()), (160 / 8)); + return success; + } + + bool isValueH160 () const; + +private: + virtual STAccount* duplicate () const + { + return new STAccount (*this); + } + static STAccount* construct (SerializerIterator&, SField::ref); +}; + +} // ripple + +#endif diff --git a/src/ripple/protocol/STAmount.h b/src/ripple/protocol/STAmount.h index 4502cd6baa..639716865a 100644 --- a/src/ripple/protocol/STAmount.h +++ b/src/ripple/protocol/STAmount.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include // @@ -38,7 +38,7 @@ namespace ripple { // Wire form: // High 8 bits are (offset+142), legal range is, 80 to 22 inclusive // Low 56 bits are value, legal range is 10^15 to (10^16 - 1) inclusive -class STAmount : public SerializedType +class STAmount : public STBase { public: typedef std::uint64_t mantissa_type; @@ -115,7 +115,7 @@ public: createFromInt64 (SField::ref n, std::int64_t v); static - std::unique_ptr + std::unique_ptr deserialize ( SerializerIterator& sit, SField::ref name) { @@ -263,7 +263,7 @@ public: //-------------------------------------------------------------------------- // - // SerializedType + // STBase // //-------------------------------------------------------------------------- @@ -286,7 +286,7 @@ public: add (Serializer& s) const override; bool - isEquivalent (const SerializedType& t) const override; + isEquivalent (const STBase& t) const override; bool isDefault() const override diff --git a/src/ripple/protocol/STArray.h b/src/ripple/protocol/STArray.h index de338be108..ba66188957 100644 --- a/src/ripple/protocol/STArray.h +++ b/src/ripple/protocol/STArray.h @@ -27,7 +27,7 @@ namespace ripple { class STArray final - : public SerializedType + : public STBase , public CountedObject { public: @@ -50,15 +50,15 @@ public: { value.reserve (n); } - explicit STArray (SField::ref f) : SerializedType (f) + explicit STArray (SField::ref f) : STBase (f) { ; } - STArray (SField::ref f, int n) : SerializedType (f) + STArray (SField::ref f, int n) : STBase (f) { value.reserve (n); } - STArray (SField::ref f, const vector & v) : SerializedType (f), value (v) + STArray (SField::ref f, const vector & v) : STBase (f), value (v) { ; } @@ -69,7 +69,7 @@ public: virtual ~STArray () { } - static std::unique_ptr + static std::unique_ptr deserialize (SerializerIterator & sit, SField::ref name); const vector& getValue () const @@ -191,7 +191,7 @@ public: { return STI_ARRAY; } - virtual bool isEquivalent (const SerializedType & t) const override; + virtual bool isEquivalent (const STBase & t) const override; virtual bool isDefault () const override { return value.empty (); diff --git a/src/ripple/protocol/STBase.h b/src/ripple/protocol/STBase.h new file mode 100644 index 0000000000..27be58f559 --- /dev/null +++ b/src/ripple/protocol/STBase.h @@ -0,0 +1,162 @@ +//------------------------------------------------------------------------------ +/* + 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. +*/ +//============================================================================== + +#ifndef RIPPLE_PROTOCOL_STBASE_H_INCLUDED +#define RIPPLE_PROTOCOL_STBASE_H_INCLUDED + +#include +#include +#include +#include +#include + +namespace ripple { + +// VFALCO TODO fix this restriction on copy assignment. +// +// CAUTION: Do not create a vector (or similar container) of any object derived +// from STBase. Use Boost ptr_* containers. The copy assignment operator +// of STBase has semantics that will cause contained types to change +// their names when an object is deleted because copy assignment is used to +// "slide down" the remaining types and this will not copy the field +// name. Changing the copy assignment operator to copy the field name breaks the +// use of copy assignment just to copy values, which is used in the transaction +// engine code. + +//------------------------------------------------------------------------------ + +/** A type which can be exported to a well known binary format. + + A STBase: + - Always a field + - Can always go inside an eligible enclosing STBase + (such as STArray) + - Has a field name + + Like JSON, a SerializedObject is a basket which has rules + on what it can hold. + + @note "ST" stands for "Serialized Type." +*/ +class STBase +{ +public: + STBase(); + + explicit + STBase (SField::ref n); + + virtual ~STBase() = default; + + STBase& operator= (const STBase& t); + + bool operator== (const STBase& t) const; + bool operator!= (const STBase& t) const; + + template + D& + downcast() + { + D* ptr = dynamic_cast (this); + if (ptr == nullptr) + throw std::bad_cast(); + return *ptr; + } + + template + D const& + downcast() const + { + D const * ptr = dynamic_cast (this); + if (ptr == nullptr) + throw std::bad_cast(); + return *ptr; + } + + virtual + SerializedTypeID + getSType() const; + + virtual + std::string + getFullText() const; + + virtual + std::string + getText() const; + + virtual + Json::Value + getJson (int /*options*/) const; + + virtual + void + add (Serializer& s) const; + + virtual + bool + isEquivalent (STBase const& t) const; + + virtual + bool + isDefault() const; + + /** A STBase is a field. + This sets the name. + */ + void + setFName (SField::ref n); + + SField::ref + getFName() const; + + std::unique_ptr + clone() const; + + void + addFieldID (Serializer& s) const; + + static + std::unique_ptr + deserialize (SField::ref name); + +protected: + SField::ptr fName; + +private: + // VFALCO TODO Return std::unique_ptr + virtual + STBase* + duplicate() const + { + return new STBase (*fName); + } +}; + +//------------------------------------------------------------------------------ + +STBase* new_clone (const STBase& s); + +void delete_clone (const STBase* s); + +std::ostream& operator<< (std::ostream& out, const STBase& t); + +} // ripple + +#endif diff --git a/src/ripple/protocol/STBitString.h b/src/ripple/protocol/STBitString.h index fb08ce0ec6..0c69303761 100644 --- a/src/ripple/protocol/STBitString.h +++ b/src/ripple/protocol/STBitString.h @@ -20,39 +20,39 @@ #ifndef RIPPLE_PROTOCOL_STBITS_H_INCLUDED #define RIPPLE_PROTOCOL_STBITS_H_INCLUDED -#include +#include namespace ripple { template -class STBitString : public SerializedType +class STBitString : public STBase { public: typedef base_uint BitString; STBitString () {} - STBitString (SField::ref n) : SerializedType (n) {} + STBitString (SField::ref n) : STBase (n) {} STBitString (const BitString& v) : bitString_ (v) {} STBitString (SField::ref n, const BitString& v) - : SerializedType (n), bitString_ (v) + : STBase (n), bitString_ (v) { } - STBitString (SField::ref n, const char* v) : SerializedType (n) + STBitString (SField::ref n, const char* v) : STBase (n) { bitString_.SetHex (v); } - STBitString (SField::ref n, std::string const& v) : SerializedType (n) + STBitString (SField::ref n, std::string const& v) : STBase (n) { bitString_.SetHex (v); } - static std::unique_ptr deserialize ( + static std::unique_ptr deserialize ( SerializerIterator& sit, SField::ref name) { - return std::unique_ptr (construct (sit, name)); + return std::unique_ptr (construct (sit, name)); } SerializedTypeID getSType () const; @@ -62,7 +62,7 @@ public: return to_string (bitString_); } - bool isEquivalent (const SerializedType& t) const + bool isEquivalent (const STBase& t) const { const STBitString* v = dynamic_cast (&t); return v && (bitString_ == v->bitString_); diff --git a/src/ripple/protocol/STBlob.h b/src/ripple/protocol/STBlob.h new file mode 100644 index 0000000000..68466569de --- /dev/null +++ b/src/ripple/protocol/STBlob.h @@ -0,0 +1,106 @@ +//------------------------------------------------------------------------------ +/* + 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. +*/ +//============================================================================== + +#ifndef RIPPLE_PROTOCOL_STBLOB_H_INCLUDED +#define RIPPLE_PROTOCOL_STBLOB_H_INCLUDED + +#include +#include + +namespace ripple { + +// variable length byte string +class STBlob : public STBase +{ +public: + STBlob (Blob const& v) : value (v) + { + ; + } + STBlob (SField::ref n, Blob const& v) : STBase (n), value (v) + { + ; + } + STBlob (SField::ref n) : STBase (n) + { + ; + } + STBlob (SerializerIterator&, SField::ref name = sfGeneric); + STBlob () + { + ; + } + static std::unique_ptr deserialize (SerializerIterator& sit, SField::ref name) + { + return std::unique_ptr (construct (sit, name)); + } + + virtual SerializedTypeID getSType () const + { + return STI_VL; + } + virtual std::string getText () const; + void add (Serializer& s) const + { + assert (fName->isBinary ()); + assert ((fName->fieldType == STI_VL) || + (fName->fieldType == STI_ACCOUNT)); + s.addVL (value); + } + + Blob const& peekValue () const + { + return value; + } + Blob& peekValue () + { + return value; + } + Blob getValue () const + { + return value; + } + void setValue (Blob const& v) + { + value = v; + } + + operator Blob () const + { + return value; + } + virtual bool isEquivalent (const STBase& t) const; + virtual bool isDefault () const + { + return value.empty (); + } + +private: + Blob value; + + virtual STBlob* duplicate () const + { + return new STBlob (*this); + } + static STBlob* construct (SerializerIterator&, SField::ref); +}; + +} // ripple + +#endif diff --git a/src/ripple/protocol/STInteger.h b/src/ripple/protocol/STInteger.h index 52095c7752..4a3f8b6f11 100644 --- a/src/ripple/protocol/STInteger.h +++ b/src/ripple/protocol/STInteger.h @@ -20,26 +20,26 @@ #ifndef RIPPLE_PROTOCOL_STINTEGER_H_INCLUDED #define RIPPLE_PROTOCOL_STINTEGER_H_INCLUDED -#include +#include namespace ripple { template -class STInteger : public SerializedType +class STInteger : public STBase { public: explicit STInteger (Integer v) : value_ (v) { } - STInteger (SField::ref n, Integer v = 0) : SerializedType (n), value_ (v) + STInteger (SField::ref n, Integer v = 0) : STBase (n), value_ (v) { } - static std::unique_ptr deserialize ( + static std::unique_ptr deserialize ( SerializerIterator& sit, SField::ref name) { - return std::unique_ptr (construct (sit, name)); + return std::unique_ptr (construct (sit, name)); } SerializedTypeID getSType () const @@ -75,7 +75,7 @@ public: return value_ == 0; } - bool isEquivalent (const SerializedType& t) const + bool isEquivalent (const STBase& t) const { const STInteger* v = dynamic_cast (&t); return v && (value_ == v->value_); diff --git a/src/ripple/app/misc/SerializedLedger.h b/src/ripple/protocol/STLedgerEntry.h similarity index 67% rename from src/ripple/app/misc/SerializedLedger.h rename to src/ripple/protocol/STLedgerEntry.h index 0f68e1f104..41fe88cde1 100644 --- a/src/ripple/app/misc/SerializedLedger.h +++ b/src/ripple/protocol/STLedgerEntry.h @@ -17,44 +17,29 @@ */ //============================================================================== -#ifndef RIPPLE_SERIALIZEDLEDGER_H -#define RIPPLE_SERIALIZEDLEDGER_H +#ifndef RIPPLE_PROTOCOL_STLEDGERENTRY_H_INCLUDED +#define RIPPLE_PROTOCOL_STLEDGERENTRY_H_INCLUDED #include #include namespace ripple { -// VFALCO NOTE -// -// This looks like a central class for Ripple. Almost everything that -// does anything of interest deals with SLE objects. Any documentation -// effort should start with a complete description of this object and -// all of its operations. -// -// It is derived from STObject so it inherits a lot of behavior from that. -// -// VFALCO TODO Rename the source file to match the class -// -// VFALCO TODO Can we rename this class to something shorter and more concise? -// -// Can we just call this LedgerEntry? -// -class SerializedLedgerEntry +class STLedgerEntry : public STObject - , public CountedObject + , public CountedObject { public: - static char const* getCountedObjectName () { return "SerializedLedgerEntry"; } + static char const* getCountedObjectName () { return "STLedgerEntry"; } - typedef std::shared_ptr pointer; - typedef const std::shared_ptr& ref; + typedef std::shared_ptr pointer; + typedef const std::shared_ptr& ref; public: - SerializedLedgerEntry (const Serializer & s, uint256 const& index); - SerializedLedgerEntry (SerializerIterator & sit, uint256 const& index); - SerializedLedgerEntry (LedgerEntryType type, uint256 const& index); - SerializedLedgerEntry (const STObject & object, uint256 const& index); + STLedgerEntry (const Serializer & s, uint256 const& index); + STLedgerEntry (SerializerIterator & sit, uint256 const& index); + STLedgerEntry (LedgerEntryType type, uint256 const& index); + STLedgerEntry (const STObject & object, uint256 const& index); SerializedTypeID getSType () const { @@ -81,7 +66,7 @@ public: { return mMutable; } - SerializedLedgerEntry::pointer getMutable () const; + STLedgerEntry::pointer getMutable () const; LedgerEntryType getType () const { @@ -110,9 +95,9 @@ public: std::vector getOwners (); // nodes notified if this node is deleted private: - SerializedLedgerEntry* duplicate () const + STLedgerEntry* duplicate () const { - return new SerializedLedgerEntry (*this); + return new STLedgerEntry (*this); } /** Make STObject comply with the template for this SLE type @@ -127,7 +112,7 @@ private: bool mMutable; }; -typedef SerializedLedgerEntry SLE; +using SLE = STLedgerEntry; } // ripple diff --git a/src/ripple/protocol/STObject.h b/src/ripple/protocol/STObject.h index 6e97502f9c..0e8c9c333b 100644 --- a/src/ripple/protocol/STObject.h +++ b/src/ripple/protocol/STObject.h @@ -22,9 +22,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include namespace ripple { @@ -32,7 +32,7 @@ namespace ripple { class STArray; class STObject - : public SerializedType + : public STBase , public CountedObject { public: @@ -44,27 +44,27 @@ public: } explicit STObject (SField::ref name) - : SerializedType (name), mType (nullptr) + : STBase (name), mType (nullptr) { ; } STObject (const SOTemplate & type, SField::ref name) - : SerializedType (name) + : STBase (name) { set (type); } STObject ( const SOTemplate & type, SerializerIterator & sit, SField::ref name) - : SerializedType (name) + : STBase (name) { set (sit); setType (type); } - STObject (SField::ref name, boost::ptr_vector& data) - : SerializedType (name), mType (nullptr) + STObject (SField::ref name, boost::ptr_vector& data) + : STBase (name), mType (nullptr) { mData.swap (data); } @@ -76,7 +76,7 @@ public: virtual ~STObject () { } - static std::unique_ptr + static std::unique_ptr deserialize (SerializerIterator & sit, SField::ref name); bool setType (const SOTemplate & type); @@ -94,7 +94,7 @@ public: { return STI_OBJECT; } - virtual bool isEquivalent (const SerializedType & t) const override; + virtual bool isEquivalent (const STBase & t) const override; virtual bool isDefault () const override { return mData.empty (); @@ -123,42 +123,42 @@ public: // TODO(tom): options should be an enum. virtual Json::Value getJson (int options) const override; - int addObject (const SerializedType & t) + int addObject (const STBase & t) { mData.push_back (t.clone ().release ()); return mData.size () - 1; } - int giveObject (std::unique_ptr t) + int giveObject (std::unique_ptr t) { mData.push_back (t.release ()); return mData.size () - 1; } - int giveObject (SerializedType * t) + int giveObject (STBase * t) { mData.push_back (t); return mData.size () - 1; } - const boost::ptr_vector& peekData () const + const boost::ptr_vector& peekData () const { return mData; } - boost::ptr_vector& peekData () + boost::ptr_vector& peekData () { return mData; } - SerializedType& front () + STBase& front () { return mData.front (); } - const SerializedType& front () const + const STBase& front () const { return mData.front (); } - SerializedType& back () + STBase& back () { return mData.back (); } - const SerializedType& back () const + const STBase& back () const { return mData.back (); } @@ -176,19 +176,19 @@ public: uint256 getHash (std::uint32_t prefix) const; uint256 getSigningHash (std::uint32_t prefix) const; - const SerializedType& peekAtIndex (int offset) const + const STBase& peekAtIndex (int offset) const { return mData[offset]; } - SerializedType& getIndex (int offset) + STBase& getIndex (int offset) { return mData[offset]; } - const SerializedType* peekAtPIndex (int offset) const + const STBase* peekAtPIndex (int offset) const { return & (mData[offset]); } - SerializedType* getPIndex (int offset) + STBase* getPIndex (int offset) { return & (mData[offset]); } @@ -196,10 +196,10 @@ public: int getFieldIndex (SField::ref field) const; SField::ref getFieldSType (int index) const; - const SerializedType& peekAtField (SField::ref field) const; - SerializedType& getField (SField::ref field); - const SerializedType* peekAtPField (SField::ref field) const; - SerializedType* getPField (SField::ref field, bool createOkay = false); + const STBase& peekAtField (SField::ref field) const; + STBase& getField (SField::ref field); + const STBase* peekAtPField (SField::ref field) const; + STBase* getPField (SField::ref field, bool createOkay = false); // these throw if the field type doesn't match, or return default values // if the field is optional but not present @@ -241,7 +241,7 @@ public: template void setFieldH160 (SField::ref field, base_uint<160, Tag> const& v) { - SerializedType* rf = getPField (field, true); + STBase* rf = getPField (field, true); if (!rf) throw std::runtime_error ("Field not found"); @@ -259,35 +259,35 @@ public: STObject& peekFieldObject (SField::ref field); bool isFieldPresent (SField::ref field) const; - SerializedType* makeFieldPresent (SField::ref field); + STBase* makeFieldPresent (SField::ref field); void makeFieldAbsent (SField::ref field); bool delField (SField::ref field); void delField (int index); - static std::unique_ptr + static std::unique_ptr makeDefaultObject (SerializedTypeID id, SField::ref name); // VFALCO TODO remove the 'depth' parameter - static std::unique_ptr makeDeserializedObject ( + static std::unique_ptr makeDeserializedObject ( SerializedTypeID id, SField::ref name, SerializerIterator&, int depth); - static std::unique_ptr + static std::unique_ptr makeNonPresentObject (SField::ref name) { return makeDefaultObject (STI_NOTPRESENT, name); } - static std::unique_ptr makeDefaultObject (SField::ref name) + static std::unique_ptr makeDefaultObject (SField::ref name) { return makeDefaultObject (name.fieldType, name); } // field iterator stuff - typedef boost::ptr_vector::iterator iterator; - typedef boost::ptr_vector::const_iterator const_iterator; + typedef boost::ptr_vector::iterator iterator; + typedef boost::ptr_vector::const_iterator const_iterator; iterator begin () { return mData.begin (); @@ -309,7 +309,7 @@ public: return mData.empty (); } - bool hasMatchingEntry (const SerializedType&); + bool hasMatchingEntry (const STBase&); bool operator== (const STObject & o) const; bool operator!= (const STObject & o) const @@ -333,7 +333,7 @@ private: decltype (std::declval ().getValue ())>::type >::type > V getFieldByValue (SField::ref field) const { - const SerializedType* rf = peekAtPField (field); + const STBase* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); @@ -359,7 +359,7 @@ private: template V const& getFieldByConstRef (SField::ref field, V const& empty) const { - const SerializedType* rf = peekAtPField (field); + const STBase* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); @@ -381,7 +381,7 @@ private: template void setFieldUsingSetValue (SField::ref field, V value) { - SerializedType* rf = getPField (field, true); + STBase* rf = getPField (field, true); if (!rf) throw std::runtime_error ("Field not found"); @@ -401,7 +401,7 @@ private: template void setFieldUsingAssignment (SField::ref field, T const& value) { - SerializedType* rf = getPField (field, true); + STBase* rf = getPField (field, true); if (!rf) throw std::runtime_error ("Field not found"); @@ -418,7 +418,7 @@ private: } private: - boost::ptr_vector mData; + boost::ptr_vector mData; const SOTemplate* mType; }; diff --git a/src/ripple/protocol/SerializedTypes.h b/src/ripple/protocol/STPathSet.h similarity index 52% rename from src/ripple/protocol/SerializedTypes.h rename to src/ripple/protocol/STPathSet.h index f0eb05a41c..93c72d7e16 100644 --- a/src/ripple/protocol/SerializedTypes.h +++ b/src/ripple/protocol/STPathSet.h @@ -17,162 +17,14 @@ */ //============================================================================== -#ifndef RIPPLE_PROTOCOL_SERIALIZEDTYPES_H_INCLUDED -#define RIPPLE_PROTOCOL_SERIALIZEDTYPES_H_INCLUDED +#ifndef RIPPLE_PROTOCOL_STPATHELEMENT_H_INCLUDED +#define RIPPLE_PROTOCOL_STPATHELEMENT_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include +#include namespace ripple { -//------------------------------------------------------------------------------ - -// variable length byte string -class STVariableLength : public SerializedType -{ -public: - STVariableLength (Blob const& v) : value (v) - { - ; - } - STVariableLength (SField::ref n, Blob const& v) : SerializedType (n), value (v) - { - ; - } - STVariableLength (SField::ref n) : SerializedType (n) - { - ; - } - STVariableLength (SerializerIterator&, SField::ref name = sfGeneric); - STVariableLength () - { - ; - } - static std::unique_ptr deserialize (SerializerIterator& sit, SField::ref name) - { - return std::unique_ptr (construct (sit, name)); - } - - virtual SerializedTypeID getSType () const - { - return STI_VL; - } - virtual std::string getText () const; - void add (Serializer& s) const - { - assert (fName->isBinary ()); - assert ((fName->fieldType == STI_VL) || - (fName->fieldType == STI_ACCOUNT)); - s.addVL (value); - } - - Blob const& peekValue () const - { - return value; - } - Blob& peekValue () - { - return value; - } - Blob getValue () const - { - return value; - } - void setValue (Blob const& v) - { - value = v; - } - - operator Blob () const - { - return value; - } - virtual bool isEquivalent (const SerializedType& t) const; - virtual bool isDefault () const - { - return value.empty (); - } - -private: - Blob value; - - virtual STVariableLength* duplicate () const - { - return new STVariableLength (*this); - } - static STVariableLength* construct (SerializerIterator&, SField::ref); -}; - -//------------------------------------------------------------------------------ - -class STAccount : public STVariableLength -{ -public: - STAccount (Blob const& v) : STVariableLength (v) - { - ; - } - STAccount (SField::ref n, Blob const& v) : STVariableLength (n, v) - { - ; - } - STAccount (SField::ref n, Account const& v); - STAccount (SField::ref n) : STVariableLength (n) - { - ; - } - STAccount () - { - ; - } - static std::unique_ptr deserialize (SerializerIterator& sit, SField::ref name) - { - return std::unique_ptr (construct (sit, name)); - } - - SerializedTypeID getSType () const - { - return STI_ACCOUNT; - } - std::string getText () const; - - RippleAddress getValueNCA () const; - void setValueNCA (RippleAddress const& nca); - - template - void setValueH160 (base_uint<160, Tag> const& v) - { - peekValue ().clear (); - peekValue ().insert (peekValue ().end (), v.begin (), v.end ()); - assert (peekValue ().size () == (160 / 8)); - } - - template - bool getValueH160 (base_uint<160, Tag>& v) const - { - auto success = isValueH160 (); - if (success) - memcpy (v.begin (), & (peekValue ().front ()), (160 / 8)); - return success; - } - - bool isValueH160 () const; - -private: - virtual STAccount* duplicate () const - { - return new STAccount (*this); - } - static STAccount* construct (SerializerIterator&, SField::ref); -}; - -//------------------------------------------------------------------------------ - +// VFALCO Why isn't this derived from STBase? class STPathElement { public: @@ -273,8 +125,6 @@ private: std::size_t hash_value_; }; -//------------------------------------------------------------------------------ - class STPath { public: @@ -348,20 +198,20 @@ private: //------------------------------------------------------------------------------ // A set of zero or more payment paths -class STPathSet : public SerializedType +class STPathSet : public STBase { public: STPathSet () = default; STPathSet (SField::ref n) - : SerializedType (n) + : STBase (n) { } static - std::unique_ptr + std::unique_ptr deserialize (SerializerIterator& sit, SField::ref name) { - return std::unique_ptr (construct (sit, name)); + return std::unique_ptr (construct (sit, name)); } void add (Serializer& s) const; @@ -407,7 +257,7 @@ public: return true; } - virtual bool isEquivalent (const SerializedType& t) const; + virtual bool isEquivalent (const STBase& t) const; virtual bool isDefault () const { return value.empty (); @@ -433,7 +283,7 @@ private: std::vector value; STPathSet (SField::ref n, const std::vector& v) - : SerializedType (n), value (v) + : STBase (n), value (v) { } STPathSet* duplicate () const @@ -446,104 +296,6 @@ private: construct (SerializerIterator&, SField::ref); }; -//------------------------------------------------------------------------------ - -class STVector256 : public SerializedType -{ -public: - STVector256 () = default; - explicit STVector256 (SField::ref n) - : SerializedType (n) - { } - explicit STVector256 (std::vector const& vector) - : mValue (vector) - { } - - SerializedTypeID getSType () const - { - return STI_VECTOR256; - } - void add (Serializer& s) const; - - static - std::unique_ptr - deserialize (SerializerIterator& sit, SField::ref name) - { - return std::unique_ptr (construct (sit, name)); - } - - const std::vector& - peekValue () const - { - return mValue; - } - - std::vector& - peekValue () - { - return mValue; - } - - virtual bool isEquivalent (const SerializedType& t) const; - virtual bool isDefault () const - { - return mValue.empty (); - } - - std::vector::size_type - size () const - { - return mValue.size (); - } - bool empty () const - { - return mValue.empty (); - } - - std::vector::const_reference - operator[] (std::vector::size_type n) const - { - return mValue[n]; - } - - void setValue (const STVector256& v) - { - mValue = v.mValue; - } - - void push_back (uint256 const& v) - { - mValue.push_back (v); - } - - void sort () - { - std::sort (mValue.begin (), mValue.end ()); - } - - Json::Value getJson (int) const; - - std::vector::const_iterator - begin() const - { - return mValue.begin (); - } - std::vector::const_iterator - end() const - { - return mValue.end (); - } - -private: - std::vector mValue; - - STVector256* duplicate () const - { - return new STVector256 (*this); - } - static STVector256* construct (SerializerIterator&, SField::ref); -}; - } // ripple #endif diff --git a/src/ripple/app/misc/SerializedTransaction.h b/src/ripple/protocol/STTx.h similarity index 83% rename from src/ripple/app/misc/SerializedTransaction.h rename to src/ripple/protocol/STTx.h index fc88978d03..1d1b1d911b 100644 --- a/src/ripple/app/misc/SerializedTransaction.h +++ b/src/ripple/protocol/STTx.h @@ -34,27 +34,27 @@ namespace ripple { #define TXN_SQL_INCLUDED 'I' #define TXN_SQL_UNKNOWN 'U' -class SerializedTransaction +class STTx : public STObject - , public CountedObject + , public CountedObject { public: - static char const* getCountedObjectName () { return "SerializedTransaction"; } + static char const* getCountedObjectName () { return "STTx"; } - typedef std::shared_ptr pointer; - typedef const std::shared_ptr& ref; + typedef std::shared_ptr pointer; + typedef const std::shared_ptr& ref; public: - SerializedTransaction () = delete; - SerializedTransaction& operator= (SerializedTransaction const& other) = delete; + STTx () = delete; + STTx& operator= (STTx const& other) = delete; - SerializedTransaction (SerializedTransaction const& other) = default; + STTx (STTx const& other) = default; - explicit SerializedTransaction (SerializerIterator& sit); - explicit SerializedTransaction (TxType type); + explicit STTx (SerializerIterator& sit); + explicit STTx (TxType type); // Only called from ripple::RPC::transactionSign - can we eliminate this? - explicit SerializedTransaction (STObject const& object); + explicit STTx (STObject const& object); // STObject functions SerializedTypeID getSType () const @@ -145,9 +145,9 @@ public: std::string const& escapedMetaData) const; private: - SerializedTransaction* duplicate () const override + STTx* duplicate () const override { - return new SerializedTransaction (*this); + return new STTx (*this); } TxType tx_type_; diff --git a/src/ripple/app/ledger/SerializedValidation.h b/src/ripple/protocol/STValidation.h similarity index 86% rename from src/ripple/app/ledger/SerializedValidation.h rename to src/ripple/protocol/STValidation.h index 99c1ae48e1..7ffbf698aa 100644 --- a/src/ripple/app/ledger/SerializedValidation.h +++ b/src/ripple/protocol/STValidation.h @@ -25,15 +25,15 @@ namespace ripple { // Validation flags const std::uint32_t vfFullyCanonicalSig = 0x80000000; // signature is fully canonical -class SerializedValidation +class STValidation : public STObject - , public CountedObject + , public CountedObject { public: - static char const* getCountedObjectName () { return "SerializedValidation"; } + static char const* getCountedObjectName () { return "STValidation"; } - typedef std::shared_ptr pointer; - typedef const std::shared_ptr& ref; + typedef std::shared_ptr pointer; + typedef const std::shared_ptr& ref; enum { @@ -41,10 +41,10 @@ public: }; // These throw if the object is not valid - SerializedValidation (SerializerIterator & sit, bool checkSignature = true); + STValidation (SerializerIterator & sit, bool checkSignature = true); // Does not sign the validation - SerializedValidation (uint256 const& ledgerHash, std::uint32_t signTime, + STValidation (uint256 const& ledgerHash, std::uint32_t signTime, const RippleAddress & raPub, bool isFull); uint256 getLedgerHash () const; diff --git a/src/ripple/protocol/STVector256.h b/src/ripple/protocol/STVector256.h new file mode 100644 index 0000000000..10b329ab5a --- /dev/null +++ b/src/ripple/protocol/STVector256.h @@ -0,0 +1,128 @@ +//------------------------------------------------------------------------------ +/* + 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. +*/ +//============================================================================== + +#ifndef RIPPLE_PROTOCOL_SERIALIZEDTYPES_H_INCLUDED +#define RIPPLE_PROTOCOL_SERIALIZEDTYPES_H_INCLUDED + +#include +#include +#include +#include + +namespace ripple { + +class STVector256 : public STBase +{ +public: + STVector256 () = default; + explicit STVector256 (SField::ref n) + : STBase (n) + { } + explicit STVector256 (std::vector const& vector) + : mValue (vector) + { } + + SerializedTypeID getSType () const + { + return STI_VECTOR256; + } + void add (Serializer& s) const; + + static + std::unique_ptr + deserialize (SerializerIterator& sit, SField::ref name) + { + return std::unique_ptr (construct (sit, name)); + } + + const std::vector& + peekValue () const + { + return mValue; + } + + std::vector& + peekValue () + { + return mValue; + } + + virtual bool isEquivalent (const STBase& t) const; + virtual bool isDefault () const + { + return mValue.empty (); + } + + std::vector::size_type + size () const + { + return mValue.size (); + } + bool empty () const + { + return mValue.empty (); + } + + std::vector::const_reference + operator[] (std::vector::size_type n) const + { + return mValue[n]; + } + + void setValue (const STVector256& v) + { + mValue = v.mValue; + } + + void push_back (uint256 const& v) + { + mValue.push_back (v); + } + + void sort () + { + std::sort (mValue.begin (), mValue.end ()); + } + + Json::Value getJson (int) const; + + std::vector::const_iterator + begin() const + { + return mValue.begin (); + } + std::vector::const_iterator + end() const + { + return mValue.end (); + } + +private: + std::vector mValue; + + STVector256* duplicate () const + { + return new STVector256 (*this); + } + static STVector256* construct (SerializerIterator&, SField::ref); +}; + +} // ripple + +#endif diff --git a/src/ripple/protocol/SerializedType.h b/src/ripple/protocol/SerializedType.h deleted file mode 100644 index 49c06a746a..0000000000 --- a/src/ripple/protocol/SerializedType.h +++ /dev/null @@ -1,236 +0,0 @@ -//------------------------------------------------------------------------------ -/* - 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. -*/ -//============================================================================== - -#ifndef RIPPLE_PROTOCOL_SERIALIZEDTYPE_H_INCLUDED -#define RIPPLE_PROTOCOL_SERIALIZEDTYPE_H_INCLUDED - -#include -#include - -namespace ripple { - -// VFALCO TODO fix this restriction on copy assignment. -// -// CAUTION: Do not create a vector (or similar container) of any object derived -// from SerializedType. Use Boost ptr_* containers. The copy assignment operator -// of SerializedType has semantics that will cause contained types to change -// their names when an object is deleted because copy assignment is used to -// "slide down" the remaining types and this will not copy the field -// name. Changing the copy assignment operator to copy the field name breaks the -// use of copy assignment just to copy values, which is used in the transaction -// engine code. - -// VFALCO TODO Remove this unused enum -/* -enum PathFlags -{ - PF_END = 0x00, // End of current path & path list. - PF_BOUNDARY = 0xFF, // End of current path & new path follows. - - PF_ACCOUNT = 0x01, - PF_OFFER = 0x02, - - PF_WANTED_CURRENCY = 0x10, - PF_WANTED_ISSUER = 0x20, - PF_REDEEM = 0x40, - PF_ISSUE = 0x80, -}; -*/ - -//------------------------------------------------------------------------------ - -/** A type which can be exported to a well known binary format. - - A SerializedType: - - Always a field - - Can always go inside an eligible enclosing SerializedType - (such as STArray) - - Has a field name - - - Like JSON, a SerializedObject is a basket which has rules - on what it can hold. -*/ -// VFALCO TODO Document this as it looks like a central class. -// STObject is derived from it -// -class SerializedType -{ -public: - SerializedType () : fName (&sfGeneric) - { - ; - } - - explicit SerializedType (SField::ref n) : fName (&n) - { - assert (fName); - } - - virtual ~SerializedType () = default; - - // - // overridables - // - - virtual - SerializedTypeID - getSType () const - { - return STI_NOTPRESENT; - } - - virtual - std::string - getFullText() const; - - // just the value - virtual - std::string - getText() const - { - return std::string(); - } - - virtual - Json::Value getJson (int /*options*/) const - { - return getText(); - } - - virtual - void - add (Serializer& s) const - { - // VFALCO Why not just make this pure virtual? - assert (false); - } - - virtual - bool - isEquivalent (SerializedType const& t) const; - - virtual - bool - isDefault () const - { - return true; - } - -private: - // VFALCO TODO Return std::unique_ptr - virtual - SerializedType* - duplicate () const - { - return new SerializedType (*fName); - } - -public: - // - // members - // - - static - std::unique_ptr - deserialize (SField::ref name) - { - return std::unique_ptr (new SerializedType (name)); - } - - /** A SerializedType is a field. - This sets the name. - */ - void setFName (SField::ref n) - { - fName = &n; - assert (fName); - } - SField::ref getFName () const - { - return *fName; - } - std::unique_ptr clone () const - { - return std::unique_ptr (duplicate ()); - } - - - void addFieldID (Serializer& s) const - { - assert (fName->isBinary ()); - s.addFieldID (fName->fieldType, fName->fieldValue); - } - - SerializedType& operator= (const SerializedType& t); - - bool operator== (const SerializedType& t) const - { - return (getSType () == t.getSType ()) && isEquivalent (t); - } - bool operator!= (const SerializedType& t) const - { - return (getSType () != t.getSType ()) || !isEquivalent (t); - } - - template - D& downcast() - { - D* ptr = dynamic_cast (this); - if (ptr == nullptr) - throw std::runtime_error ("type mismatch"); - return *ptr; - } - - template - D const& downcast() const - { - D const * ptr = dynamic_cast (this); - if (ptr == nullptr) - throw std::runtime_error ("type mismatch"); - return *ptr; - } - -protected: - // VFALCO TODO make accessors for this - SField::ptr fName; -}; - -//------------------------------------------------------------------------------ - -inline SerializedType* new_clone (const SerializedType& s) -{ - SerializedType* const copy (s.clone ().release ()); - assert (typeid (*copy) == typeid (s)); - return copy; -} - -inline void delete_clone (const SerializedType* s) -{ - boost::checked_delete (s); -} - -inline std::ostream& operator<< (std::ostream& out, const SerializedType& t) -{ - return out << t.getFullText (); -} - -} // ripple - -#endif diff --git a/src/ripple/types/UintTypes.h b/src/ripple/protocol/UintTypes.h similarity index 100% rename from src/ripple/types/UintTypes.h rename to src/ripple/protocol/UintTypes.h diff --git a/src/ripple/protocol/impl/Indexes.cpp b/src/ripple/protocol/impl/Indexes.cpp index 49227a9fc3..60ef7abf31 100644 --- a/src/ripple/protocol/impl/Indexes.cpp +++ b/src/ripple/protocol/impl/Indexes.cpp @@ -18,13 +18,6 @@ //============================================================================== #include -#include -#include -#include - -#include -#include -#include namespace ripple { diff --git a/src/ripple/protocol/impl/SerializedObjectTemplate.cpp b/src/ripple/protocol/impl/SOTemplate.cpp similarity index 97% rename from src/ripple/protocol/impl/SerializedObjectTemplate.cpp rename to src/ripple/protocol/impl/SOTemplate.cpp index cc56482ea7..b8ac4a4475 100644 --- a/src/ripple/protocol/impl/SerializedObjectTemplate.cpp +++ b/src/ripple/protocol/impl/SOTemplate.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/STAccount.cpp b/src/ripple/protocol/impl/STAccount.cpp new file mode 100644 index 0000000000..48a0dff6ba --- /dev/null +++ b/src/ripple/protocol/impl/STAccount.cpp @@ -0,0 +1,68 @@ +//------------------------------------------------------------------------------ +/* + 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 + +namespace ripple { + +std::string STAccount::getText () const +{ + Account u; + RippleAddress a; + + if (!getValueH160 (u)) + return STBlob::getText (); + + a.setAccountID (u); + return a.humanAccountID (); +} + +STAccount* +STAccount::construct (SerializerIterator& u, SField::ref name) +{ + return new STAccount (name, u.getVL ()); +} + +STAccount::STAccount (SField::ref n, Account const& v) : STBlob (n) +{ + peekValue ().insert (peekValue ().end (), v.begin (), v.end ()); +} + +bool STAccount::isValueH160 () const +{ + return peekValue ().size () == (160 / 8); +} + +RippleAddress STAccount::getValueNCA () const +{ + RippleAddress a; + Account account; + + if (getValueH160 (account)) + a.setAccountID (account); + + return a; +} + +void STAccount::setValueNCA (RippleAddress const& nca) +{ + setValueH160 (nca.getAccountID ()); +} + +} // ripple diff --git a/src/ripple/protocol/impl/STAmount.cpp b/src/ripple/protocol/impl/STAmount.cpp index 343a97be73..fd135b61df 100644 --- a/src/ripple/protocol/impl/STAmount.cpp +++ b/src/ripple/protocol/impl/STAmount.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -39,7 +39,7 @@ static const std::uint64_t tenTo17 = tenTo14 * 1000; STAmount::STAmount (SField::ref name, Issue const& issue, mantissa_type mantissa, exponent_type exponent, bool native, bool negative) - : SerializedType (name) + : STBase (name) , mIssue (issue) , mValue (mantissa) , mOffset (exponent) @@ -52,7 +52,7 @@ STAmount::STAmount (SField::ref name, Issue const& issue, STAmount::STAmount (SField::ref name, Issue const& issue, mantissa_type mantissa, exponent_type exponent, bool native, bool negative, unchecked) - : SerializedType (name) + : STBase (name) , mIssue (issue) , mValue (mantissa) , mOffset (exponent) @@ -62,7 +62,7 @@ STAmount::STAmount (SField::ref name, Issue const& issue, } STAmount::STAmount (SField::ref name, std::int64_t mantissa) - : SerializedType (name) + : STBase (name) , mOffset (0) , mIsNative (true) { @@ -71,7 +71,7 @@ STAmount::STAmount (SField::ref name, std::int64_t mantissa) STAmount::STAmount (SField::ref name, std::uint64_t mantissa, bool negative) - : SerializedType (name) + : STBase (name) , mValue (mantissa) , mOffset (0) , mIsNative (true) @@ -81,7 +81,7 @@ STAmount::STAmount (SField::ref name, STAmount::STAmount (SField::ref name, Issue const& issue, std::uint64_t mantissa, int exponent, bool negative) - : SerializedType (name) + : STBase (name) , mIssue (issue) , mValue (mantissa) , mOffset (exponent) @@ -593,7 +593,7 @@ void STAmount::roundSelf () //------------------------------------------------------------------------------ // -// SerializedType +// STBase // //------------------------------------------------------------------------------ @@ -745,7 +745,7 @@ STAmount::add (Serializer& s) const } bool -STAmount::isEquivalent (const SerializedType& t) const +STAmount::isEquivalent (const STBase& t) const { const STAmount* v = dynamic_cast (&t); return v && (*v == *this); diff --git a/src/ripple/protocol/impl/STArray.cpp b/src/ripple/protocol/impl/STArray.cpp index 8c1f469204..fcca8790bc 100644 --- a/src/ripple/protocol/impl/STArray.cpp +++ b/src/ripple/protocol/impl/STArray.cpp @@ -18,12 +18,12 @@ //============================================================================== #include -#include +#include #include namespace ripple { -std::unique_ptr +std::unique_ptr STArray::deserialize (SerializerIterator& sit, SField::ref field) { std::unique_ptr ret (std::make_unique (field)); @@ -130,7 +130,7 @@ void STArray::add (Serializer& s) const } } -bool STArray::isEquivalent (const SerializedType& t) const +bool STArray::isEquivalent (const STBase& t) const { const STArray* v = dynamic_cast (&t); diff --git a/src/ripple/protocol/impl/STBase.cpp b/src/ripple/protocol/impl/STBase.cpp new file mode 100644 index 0000000000..f03e81e797 --- /dev/null +++ b/src/ripple/protocol/impl/STBase.cpp @@ -0,0 +1,181 @@ +//------------------------------------------------------------------------------ +/* + 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 +#include +#include +#include // + +namespace ripple { + +STBase::STBase() + : fName(&sfGeneric) +{ +} + +STBase::STBase (SField::ref n) + : fName(&n) +{ + assert(fName); +} + +STBase& +STBase::operator= (const STBase& t) +{ + if ((t.fName != fName) && fName->isUseful() && t.fName->isUseful()) + { + // VFALCO We shouldn't be logging at this low a level + /* + WriteLog ((t.getSType () == STI_AMOUNT) ? lsTRACE : lsWARNING, STBase) // This is common for amounts + << "Caution: " << t.fName->getName () << " not replacing " << fName->getName (); + */ + } + if (!fName->isUseful()) + fName = t.fName; + return *this; +} + +bool +STBase::operator== (const STBase& t) const +{ + return (getSType () == t.getSType ()) && isEquivalent (t); +} + +bool +STBase::operator!= (const STBase& t) const +{ + return (getSType () != t.getSType ()) || !isEquivalent (t); +} + +SerializedTypeID +STBase::getSType() const +{ + return STI_NOTPRESENT; +} + +std::string +STBase::getFullText() const +{ + std::string ret; + + if (getSType () != STI_NOTPRESENT) + { + if (fName->hasName ()) + { + ret = fName->fieldName; + ret += " = "; + } + + ret += getText (); + } + + return ret; +} + +std::string +STBase::getText() const +{ + return std::string(); +} + +Json::Value +STBase::getJson (int /*options*/) const +{ + return getText(); +} + +void +STBase::add (Serializer& s) const +{ + // Should never be called + assert(false); +} + +bool +STBase::isEquivalent (const STBase& t) const +{ + assert (getSType () == STI_NOTPRESENT); + if (t.getSType () == STI_NOTPRESENT) + return true; + // VFALCO We shouldn't be logging at this low a level + //WriteLog (lsDEBUG, STBase) << "notEquiv " << getFullText() << " not STI_NOTPRESENT"; + return false; +} + +bool +STBase::isDefault() const +{ + return true; +} + +void +STBase::setFName (SField::ref n) +{ + fName = &n; + assert (fName); +} + +SField::ref +STBase::getFName() const +{ + return *fName; +} + +std::unique_ptr +STBase::clone() const +{ + return std::unique_ptr (duplicate()); +} + +void +STBase::addFieldID (Serializer& s) const +{ + assert (fName->isBinary ()); + s.addFieldID (fName->fieldType, fName->fieldValue); +} + +std::unique_ptr +STBase::deserialize (SField::ref name) +{ + return std::make_unique(name); +} + +//------------------------------------------------------------------------------ + +STBase* +new_clone (const STBase& s) +{ + STBase* const copy (s.clone ().release ()); + assert (typeid (*copy) == typeid (s)); + return copy; +} + +void +delete_clone (const STBase* s) +{ + boost::checked_delete (s); +} + +std::ostream& +operator<< (std::ostream& out, const STBase& t) +{ + return out << t.getFullText (); +} + +} // ripple diff --git a/src/ripple/protocol/impl/STBlob.cpp b/src/ripple/protocol/impl/STBlob.cpp new file mode 100644 index 0000000000..1537392132 --- /dev/null +++ b/src/ripple/protocol/impl/STBlob.cpp @@ -0,0 +1,47 @@ +//------------------------------------------------------------------------------ +/* + 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 +#include + +namespace ripple { + +STBlob::STBlob (SerializerIterator& st, SField::ref name) + : STBase (name) +{ + value = st.getVL (); +} + +std::string STBlob::getText () const +{ + return strHex (value); +} + +STBlob* STBlob::construct (SerializerIterator& u, SField::ref name) +{ + return new STBlob (name, u.getVL ()); +} + +bool STBlob::isEquivalent (const STBase& t) const +{ + const STBlob* v = dynamic_cast (&t); + return v && (value == v->value); +} + +} // ripple diff --git a/src/ripple/protocol/impl/STInteger.cpp b/src/ripple/protocol/impl/STInteger.cpp index 0143dc4aef..523c143285 100644 --- a/src/ripple/protocol/impl/STInteger.cpp +++ b/src/ripple/protocol/impl/STInteger.cpp @@ -63,7 +63,7 @@ Json::Value STUInt8::getJson (int) const if (transResultInfo (static_cast (value_), token, human)) return token; else - WriteLog (lsWARNING, SerializedType) + WriteLog (lsWARNING, STBase) << "Unknown result code in metadata: " << value_; } diff --git a/src/ripple/app/misc/SerializedLedger.cpp b/src/ripple/protocol/impl/STLedgerEntry.cpp similarity index 80% rename from src/ripple/app/misc/SerializedLedger.cpp rename to src/ripple/protocol/impl/STLedgerEntry.cpp index d86c0988c3..f03eba61bf 100644 --- a/src/ripple/app/misc/SerializedLedger.cpp +++ b/src/ripple/protocol/impl/STLedgerEntry.cpp @@ -17,9 +17,12 @@ */ //============================================================================== +#include +#include + namespace ripple { -SerializedLedgerEntry::SerializedLedgerEntry ( +STLedgerEntry::STLedgerEntry ( SerializerIterator& sit, uint256 const& index) : STObject (sfLedgerEntry), mIndex (index), mMutable (true) { @@ -27,7 +30,7 @@ SerializedLedgerEntry::SerializedLedgerEntry ( setSLEType (); } -SerializedLedgerEntry::SerializedLedgerEntry ( +STLedgerEntry::STLedgerEntry ( const Serializer& s, uint256 const& index) : STObject (sfLedgerEntry), mIndex (index), mMutable (true) { @@ -37,14 +40,14 @@ SerializedLedgerEntry::SerializedLedgerEntry ( setSLEType (); } -SerializedLedgerEntry::SerializedLedgerEntry ( +STLedgerEntry::STLedgerEntry ( const STObject & object, uint256 const& index) : STObject (object), mIndex(index), mMutable (true) { setSLEType (); } -void SerializedLedgerEntry::setSLEType () +void STLedgerEntry::setSLEType () { mFormat = LedgerFormats::getInstance().findByType ( static_cast (getFieldU16 (sfLedgerEntryType))); @@ -62,7 +65,7 @@ void SerializedLedgerEntry::setSLEType () } } -SerializedLedgerEntry::SerializedLedgerEntry (LedgerEntryType type, uint256 const& index) : +STLedgerEntry::STLedgerEntry (LedgerEntryType type, uint256 const& index) : STObject (sfLedgerEntry), mIndex (index), mType (type), mMutable (true) { mFormat = LedgerFormats::getInstance().findByType (type); @@ -75,14 +78,14 @@ SerializedLedgerEntry::SerializedLedgerEntry (LedgerEntryType type, uint256 cons static_cast (mFormat->getType ())); } -SerializedLedgerEntry::pointer SerializedLedgerEntry::getMutable () const +STLedgerEntry::pointer STLedgerEntry::getMutable () const { - SerializedLedgerEntry::pointer ret = std::make_shared (std::cref (*this)); + STLedgerEntry::pointer ret = std::make_shared (std::cref (*this)); ret->mMutable = true; return ret; } -std::string SerializedLedgerEntry::getFullText () const +std::string STLedgerEntry::getFullText () const { std::string ret = "\""; ret += to_string (mIndex); @@ -94,14 +97,14 @@ std::string SerializedLedgerEntry::getFullText () const return ret; } -std::string SerializedLedgerEntry::getText () const +std::string STLedgerEntry::getText () const { return str (boost::format ("{ %s, %s }") % to_string (mIndex) % STObject::getText ()); } -Json::Value SerializedLedgerEntry::getJson (int options) const +Json::Value STLedgerEntry::getJson (int options) const { Json::Value ret (STObject::getJson (options)); @@ -110,27 +113,27 @@ Json::Value SerializedLedgerEntry::getJson (int options) const return ret; } -bool SerializedLedgerEntry::isThreadedType () +bool STLedgerEntry::isThreadedType () { return getFieldIndex (sfPreviousTxnID) != -1; } -bool SerializedLedgerEntry::isThreaded () +bool STLedgerEntry::isThreaded () { return isFieldPresent (sfPreviousTxnID); } -uint256 SerializedLedgerEntry::getThreadedTransaction () +uint256 STLedgerEntry::getThreadedTransaction () { return getFieldH256 (sfPreviousTxnID); } -std::uint32_t SerializedLedgerEntry::getThreadedLedger () +std::uint32_t STLedgerEntry::getThreadedLedger () { return getFieldU32 (sfPreviousTxnLgrSeq); } -bool SerializedLedgerEntry::thread (uint256 const& txID, std::uint32_t ledgerSeq, +bool STLedgerEntry::thread (uint256 const& txID, std::uint32_t ledgerSeq, uint256& prevTxID, std::uint32_t& prevLedgerID) { uint256 oldPrevTxID = getFieldH256 (sfPreviousTxnID); @@ -150,32 +153,32 @@ bool SerializedLedgerEntry::thread (uint256 const& txID, std::uint32_t ledgerSeq return true; } -bool SerializedLedgerEntry::hasOneOwner () +bool STLedgerEntry::hasOneOwner () { return (mType != ltACCOUNT_ROOT) && (getFieldIndex (sfAccount) != -1); } -bool SerializedLedgerEntry::hasTwoOwners () +bool STLedgerEntry::hasTwoOwners () { return mType == ltRIPPLE_STATE; } -RippleAddress SerializedLedgerEntry::getOwner () +RippleAddress STLedgerEntry::getOwner () { return getFieldAccount (sfAccount); } -RippleAddress SerializedLedgerEntry::getFirstOwner () +RippleAddress STLedgerEntry::getFirstOwner () { return RippleAddress::createAccountID (getFieldAmount (sfLowLimit).getIssuer ()); } -RippleAddress SerializedLedgerEntry::getSecondOwner () +RippleAddress STLedgerEntry::getSecondOwner () { return RippleAddress::createAccountID (getFieldAmount (sfHighLimit).getIssuer ()); } -std::vector SerializedLedgerEntry::getOwners () +std::vector STLedgerEntry::getOwners () { std::vector owners; Account account; diff --git a/src/ripple/protocol/impl/STObject.cpp b/src/ripple/protocol/impl/STObject.cpp index dfd34b1ce7..9be3d35ed5 100644 --- a/src/ripple/protocol/impl/STObject.cpp +++ b/src/ripple/protocol/impl/STObject.cpp @@ -20,7 +20,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -30,7 +31,7 @@ namespace ripple { -std::unique_ptr +std::unique_ptr STObject::makeDefaultObject (SerializedTypeID id, SField::ref name) { assert ((id == STI_NOTPRESENT) || (id == name.fieldType)); @@ -38,7 +39,7 @@ STObject::makeDefaultObject (SerializedTypeID id, SField::ref name) switch (id) { case STI_NOTPRESENT: - return std::make_unique (name); + return std::make_unique (name); case STI_UINT8: return std::make_unique (name); @@ -68,7 +69,7 @@ STObject::makeDefaultObject (SerializedTypeID id, SField::ref name) return std::make_unique (name); case STI_VL: - return std::make_unique (name); + return std::make_unique (name); case STI_ACCOUNT: return std::make_unique (name); @@ -91,14 +92,14 @@ STObject::makeDefaultObject (SerializedTypeID id, SField::ref name) } // VFALCO TODO Remove the 'depth' parameter -std::unique_ptr +std::unique_ptr STObject::makeDeserializedObject (SerializedTypeID id, SField::ref name, SerializerIterator& sit, int depth) { switch (id) { case STI_NOTPRESENT: - return SerializedType::deserialize (name); + return STBase::deserialize (name); case STI_UINT8: return STUInt8::deserialize (sit, name); @@ -128,7 +129,7 @@ STObject::makeDeserializedObject (SerializedTypeID id, SField::ref name, return STVector256::deserialize (sit, name); case STI_VL: - return STVariableLength::deserialize (sit, name); + return STBlob::deserialize (sit, name); case STI_ACCOUNT: return STAccount::deserialize (sit, name); @@ -163,12 +164,12 @@ void STObject::set (const SOTemplate& type) bool STObject::setType (const SOTemplate& type) { - boost::ptr_vector newData (type.peek ().size ()); + boost::ptr_vector newData (type.peek ().size ()); bool valid = true; mType = &type; - SerializedType** array = mData.c_array(); + STBase** array = mData.c_array(); std::size_t count = mData.size (); for (auto const& elem : type.peek ()) @@ -233,7 +234,7 @@ bool STObject::setType (const SOTemplate& type) bool STObject::isValidForType () { - boost::ptr_vector::iterator it = mData.begin (); + boost::ptr_vector::iterator it = mData.begin (); for (SOTemplate::value_type const& elem : mType->peek ()) { @@ -311,7 +312,7 @@ bool STObject::set (SerializerIterator& sit, int depth) } -std::unique_ptr +std::unique_ptr STObject::deserialize (SerializerIterator& sit, SField::ref name) { std::unique_ptr object (std::make_unique (name)); @@ -319,9 +320,9 @@ STObject::deserialize (SerializerIterator& sit, SField::ref name) return std::move (object); } -bool STObject::hasMatchingEntry (const SerializedType& t) +bool STObject::hasMatchingEntry (const STBase& t) { - const SerializedType* o = peekAtPField (t.getFName ()); + const STBase* o = peekAtPField (t.getFName ()); if (!o) return false; @@ -341,7 +342,7 @@ std::string STObject::getFullText () const } else ret = "{"; - for (SerializedType const& elem : mData) + for (STBase const& elem : mData) { if (elem.getSType () != STI_NOTPRESENT) { @@ -360,9 +361,9 @@ std::string STObject::getFullText () const void STObject::add (Serializer& s, bool withSigningFields) const { - std::map fields; + std::map fields; - for (SerializedType const& elem : mData) + for (STBase const& elem : mData) { // pick out the fields and sort them if ((elem.getSType () != STI_NOTPRESENT) && @@ -372,11 +373,11 @@ void STObject::add (Serializer& s, bool withSigningFields) const } } - typedef std::map::value_type field_iterator; + typedef std::map::value_type field_iterator; for (auto const& mapEntry : fields) { // insert them in sorted order - const SerializedType* field = mapEntry.second; + const STBase* field = mapEntry.second; // When we serialize an object inside another object, // the type associated by rule with this field name @@ -398,7 +399,7 @@ std::string STObject::getText () const { std::string ret = "{"; bool first = false; - for (SerializedType const& elem : mData) + for (STBase const& elem : mData) { if (!first) { @@ -412,7 +413,7 @@ std::string STObject::getText () const return ret; } -bool STObject::isEquivalent (const SerializedType& t) const +bool STObject::isEquivalent (const STBase& t) const { const STObject* v = dynamic_cast (&t); @@ -423,7 +424,7 @@ bool STObject::isEquivalent (const SerializedType& t) const return false; } - typedef boost::ptr_vector::const_iterator const_iter; + typedef boost::ptr_vector::const_iterator const_iter; const_iter it1 = mData.begin (), end1 = mData.end (); const_iter it2 = v->mData.begin (), end2 = v->mData.end (); @@ -473,7 +474,7 @@ int STObject::getFieldIndex (SField::ref field) const return mType->getIndex (field); int i = 0; - for (SerializedType const& elem : mData) + for (STBase const& elem : mData) { if (elem.getFName () == field) return i; @@ -483,7 +484,7 @@ int STObject::getFieldIndex (SField::ref field) const return -1; } -const SerializedType& STObject::peekAtField (SField::ref field) const +const STBase& STObject::peekAtField (SField::ref field) const { int index = getFieldIndex (field); @@ -493,7 +494,7 @@ const SerializedType& STObject::peekAtField (SField::ref field) const return peekAtIndex (index); } -SerializedType& STObject::getField (SField::ref field) +STBase& STObject::getField (SField::ref field) { int index = getFieldIndex (field); @@ -508,7 +509,7 @@ SField::ref STObject::getFieldSType (int index) const return mData[index].getFName (); } -const SerializedType* STObject::peekAtPField (SField::ref field) const +const STBase* STObject::peekAtPField (SField::ref field) const { int index = getFieldIndex (field); @@ -518,7 +519,7 @@ const SerializedType* STObject::peekAtPField (SField::ref field) const return peekAtPIndex (index); } -SerializedType* STObject::getPField (SField::ref field, bool createOkay) +STBase* STObject::getPField (SField::ref field, bool createOkay) { int index = getFieldIndex (field); @@ -545,7 +546,7 @@ bool STObject::isFieldPresent (SField::ref field) const STObject& STObject::peekFieldObject (SField::ref field) { - SerializedType* rf = getPField (field, true); + STBase* rf = getPField (field, true); if (!rf) throw std::runtime_error ("Field not found"); @@ -598,7 +599,7 @@ std::uint32_t STObject::getFlags (void) const return t->getValue (); } -SerializedType* STObject::makeFieldPresent (SField::ref field) +STBase* STObject::makeFieldPresent (SField::ref field) { int index = getFieldIndex (field); @@ -610,7 +611,7 @@ SerializedType* STObject::makeFieldPresent (SField::ref field) return getPIndex (giveObject (makeNonPresentObject (field))); } - SerializedType* f = getPIndex (index); + STBase* f = getPIndex (index); if (f->getSType () != STI_NOTPRESENT) return f; @@ -626,7 +627,7 @@ void STObject::makeFieldAbsent (SField::ref field) if (index == -1) throw std::runtime_error ("Field not found"); - const SerializedType& f = peekAtIndex (index); + const STBase& f = peekAtIndex (index); if (f.getSType () == STI_NOTPRESENT) return; @@ -652,7 +653,7 @@ void STObject::delField (int index) std::string STObject::getFieldString (SField::ref field) const { - const SerializedType* rf = peekAtPField (field); + const STBase* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); @@ -696,7 +697,7 @@ uint256 STObject::getFieldH256 (SField::ref field) const RippleAddress STObject::getFieldAccount (SField::ref field) const { - const SerializedType* rf = peekAtPField (field); + const STBase* rf = peekAtPField (field); if (!rf) throw std::runtime_error ("Field not found"); @@ -735,7 +736,7 @@ Account STObject::getFieldAccount160 (SField::ref field) const Blob STObject::getFieldVL (SField::ref field) const { - return getFieldByValue (field); + return getFieldByValue (field); } STAmount const& STObject::getFieldAmount (SField::ref field) const @@ -799,7 +800,7 @@ void STObject::setFieldV256 (SField::ref field, STVector256 const& v) void STObject::setFieldAccount (SField::ref field, Account const& v) { - SerializedType* rf = getPField (field, true); + STBase* rf = getPField (field, true); if (!rf) throw std::runtime_error ("Field not found"); @@ -817,7 +818,7 @@ void STObject::setFieldAccount (SField::ref field, Account const& v) void STObject::setFieldVL (SField::ref field, Blob const& v) { - setFieldUsingSetValue (field, v); + setFieldUsingSetValue (field, v); } void STObject::setFieldAmount (SField::ref field, STAmount const& v) @@ -859,13 +860,13 @@ bool STObject::operator== (const STObject& obj) const // This is not particularly efficient, and only compares data elements // with binary representations int matches = 0; - for (SerializedType const& t1 : mData) + for (STBase const& t1 : mData) { if ((t1.getSType () != STI_NOTPRESENT) && t1.getFName ().isBinary ()) { // each present field must have a matching field bool match = false; - for (SerializedType const& t2 : obj.mData) + for (STBase const& t2 : obj.mData) { if (t1.getFName () == t2.getFName ()) { @@ -889,7 +890,7 @@ bool STObject::operator== (const STObject& obj) const } int fields = 0; - for (SerializedType const& t2 : obj.mData) + for (STBase const& t2 : obj.mData) { if ((t2.getSType () != STI_NOTPRESENT) && t2.getFName ().isBinary ()) ++fields; diff --git a/src/ripple/protocol/impl/STParsedJSON.cpp b/src/ripple/protocol/impl/STParsedJSON.cpp index 20c9c1fbf6..748c9a8491 100644 --- a/src/ripple/protocol/impl/STParsedJSON.cpp +++ b/src/ripple/protocol/impl/STParsedJSON.cpp @@ -128,14 +128,14 @@ static Json::Value singleton_expected (std::string const& object, // This function is used by parseObject to parse any JSON type that doesn't // recurse. Everything represented here is a leaf-type. -static std::unique_ptr parseLeaf ( +static std::unique_ptr parseLeaf ( std::string const& json_name, std::string const& fieldName, SField::ptr name, Json::Value const& value, Json::Value& error) { - std::unique_ptr ret; + std::unique_ptr ret; SField::ref field = SField::getField (fieldName); @@ -406,7 +406,7 @@ static std::unique_ptr parseLeaf ( if (!vBlob.second) throw std::invalid_argument ("invalid data"); - ret = std::make_unique (field, vBlob.first); + ret = std::make_unique (field, vBlob.first); } catch (...) { @@ -680,7 +680,7 @@ static bool parseObject ( SField::ptr name (&inName); - boost::ptr_vector data; + boost::ptr_vector data; Json::Value::Members members (json.getMemberNames ()); for (Json::Value::Members::iterator it (members.begin ()); @@ -750,7 +750,7 @@ static bool parseObject ( // Everything else (types that don't recurse). default: { - std::unique_ptr serTyp = + std::unique_ptr serTyp = parseLeaf (json_name, fieldName, name, value, error); if (!serTyp) diff --git a/src/ripple/protocol/impl/SerializedTypes.cpp b/src/ripple/protocol/impl/STPathSet.cpp similarity index 56% rename from src/ripple/protocol/impl/SerializedTypes.cpp rename to src/ripple/protocol/impl/STPathSet.cpp index 9803a5ba3c..ef9ab14bf1 100644 --- a/src/ripple/protocol/impl/SerializedTypes.cpp +++ b/src/ripple/protocol/impl/STPathSet.cpp @@ -17,181 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include namespace ripple { -const STAmount saZero (noIssue(), 0u); -const STAmount saOne (noIssue(), 1u); - -SerializedType& SerializedType::operator= (const SerializedType& t) -{ - if ((t.fName != fName) && fName->isUseful () && t.fName->isUseful ()) - { - WriteLog ((t.getSType () == STI_AMOUNT) ? lsTRACE : lsWARNING, SerializedType) // This is common for amounts - << "Caution: " << t.fName->getName () << " not replacing " << fName->getName (); - } - - if (!fName->isUseful ()) fName = t.fName; - - return *this; -} - -bool SerializedType::isEquivalent (const SerializedType& t) const -{ - assert (getSType () == STI_NOTPRESENT); - if (t.getSType () == STI_NOTPRESENT) - return true; - WriteLog (lsDEBUG, SerializedType) << "notEquiv " << getFullText() << " not STI_NOTPRESENT"; - return false; -} - -std::string SerializedType::getFullText () const -{ - std::string ret; - - if (getSType () != STI_NOTPRESENT) - { - if (fName->hasName ()) - { - ret = fName->fieldName; - ret += " = "; - } - - ret += getText (); - } - - return ret; -} - -// -// STVariableLength -// - -STVariableLength::STVariableLength (SerializerIterator& st, SField::ref name) : SerializedType (name) -{ - value = st.getVL (); -} - -std::string STVariableLength::getText () const -{ - return strHex (value); -} - -STVariableLength* STVariableLength::construct (SerializerIterator& u, SField::ref name) -{ - return new STVariableLength (name, u.getVL ()); -} - -bool STVariableLength::isEquivalent (const SerializedType& t) const -{ - const STVariableLength* v = dynamic_cast (&t); - return v && (value == v->value); -} - -std::string STAccount::getText () const -{ - Account u; - RippleAddress a; - - if (!getValueH160 (u)) - return STVariableLength::getText (); - - a.setAccountID (u); - return a.humanAccountID (); -} - -STAccount* STAccount::construct (SerializerIterator& u, SField::ref name) -{ - return new STAccount (name, u.getVL ()); -} - -// -// STVector256 -// - -// Return a new object from a SerializerIterator. -STVector256* STVector256::construct (SerializerIterator& u, SField::ref name) -{ - Blob data = u.getVL (); - Blob ::iterator begin = data.begin (); - - std::unique_ptr vec (new STVector256 (name)); - - int count = data.size () / (256 / 8); - vec->mValue.reserve (count); - - unsigned int uStart = 0; - - for (unsigned int i = 0; i != count; i++) - { - unsigned int uEnd = uStart + (256 / 8); - - // This next line could be optimized to construct a default uint256 in the vector and then copy into it - vec->mValue.push_back (uint256 (Blob (begin + uStart, begin + uEnd))); - uStart = uEnd; - } - - return vec.release (); -} - -void STVector256::add (Serializer& s) const -{ - assert (fName->isBinary ()); - assert (fName->fieldType == STI_VECTOR256); - s.addVL (mValue.empty () ? nullptr : mValue[0].begin (), mValue.size () * (256 / 8)); -} - -bool STVector256::isEquivalent (const SerializedType& t) const -{ - const STVector256* v = dynamic_cast (&t); - return v && (mValue == v->mValue); -} - -Json::Value STVector256::getJson (int) const -{ - Json::Value ret (Json::arrayValue); - - for (auto const& vEntry : mValue) - ret.append (to_string (vEntry)); - - return ret; -} - -// -// STAccount -// - -STAccount::STAccount (SField::ref n, Account const& v) : STVariableLength (n) -{ - peekValue ().insert (peekValue ().end (), v.begin (), v.end ()); -} - -bool STAccount::isValueH160 () const -{ - return peekValue ().size () == (160 / 8); -} - -RippleAddress STAccount::getValueNCA () const -{ - RippleAddress a; - Account account; - - if (getValueH160 (account)) - a.setAccountID (account); - - return a; -} - -void STAccount::setValueNCA (RippleAddress const& nca) -{ - setValueH160 (nca.getAccountID ()); -} - std::size_t STPathElement::get_hash (STPathElement const& element) { @@ -229,7 +58,7 @@ STPathSet* STPathSet::construct (SerializerIterator& s, SField::ref name) { if (path.empty ()) { - WriteLog (lsINFO, SerializedType) << "STPathSet: Empty path."; + WriteLog (lsINFO, STBase) << "STPathSet: Empty path."; throw std::runtime_error ("empty path"); } @@ -244,7 +73,7 @@ STPathSet* STPathSet::construct (SerializerIterator& s, SField::ref name) } else if (iType & ~STPathElement::typeAll) { - WriteLog (lsINFO, SerializedType) + WriteLog (lsINFO, STBase) << "STPathSet: Bad path element: " << iType; throw std::runtime_error ("bad path element"); @@ -274,7 +103,7 @@ STPathSet* STPathSet::construct (SerializerIterator& s, SField::ref name) while (1); } -bool STPathSet::isEquivalent (const SerializedType& t) const +bool STPathSet::isEquivalent (const STBase& t) const { const STPathSet* v = dynamic_cast (&t); return v && (value == v->value); diff --git a/src/ripple/app/misc/SerializedTransaction.cpp b/src/ripple/protocol/impl/STTx.cpp similarity index 85% rename from src/ripple/app/misc/SerializedTransaction.cpp rename to src/ripple/protocol/impl/STTx.cpp index 0f0e35046b..03ed1ccd03 100644 --- a/src/ripple/app/misc/SerializedTransaction.cpp +++ b/src/ripple/protocol/impl/STTx.cpp @@ -19,14 +19,15 @@ #include #include +#include +#include #include #include #include -#include namespace ripple { -SerializedTransaction::SerializedTransaction (TxType type) +STTx::STTx (TxType type) : STObject (sfTransaction) , tx_type_ (type) , sig_state_ (boost::indeterminate) @@ -35,7 +36,7 @@ SerializedTransaction::SerializedTransaction (TxType type) if (format == nullptr) { - WriteLog (lsWARNING, SerializedTransaction) << + WriteLog (lsWARNING, STTx) << "Transaction type: " << type; throw std::runtime_error ("invalid transaction type"); } @@ -44,7 +45,7 @@ SerializedTransaction::SerializedTransaction (TxType type) setFieldU16 (sfTransactionType, format->getType ()); } -SerializedTransaction::SerializedTransaction (STObject const& object) +STTx::STTx (STObject const& object) : STObject (object) , sig_state_ (boost::indeterminate) { @@ -54,20 +55,20 @@ SerializedTransaction::SerializedTransaction (STObject const& object) if (!format) { - WriteLog (lsWARNING, SerializedTransaction) << + WriteLog (lsWARNING, STTx) << "Transaction type: " << tx_type_; throw std::runtime_error ("invalid transaction type"); } if (!setType (format->elements)) { - WriteLog (lsWARNING, SerializedTransaction) << + WriteLog (lsWARNING, STTx) << "Transaction not legal for format"; throw std::runtime_error ("transaction not valid"); } } -SerializedTransaction::SerializedTransaction (SerializerIterator& sit) +STTx::STTx (SerializerIterator& sit) : STObject (sfTransaction) , sig_state_ (boost::indeterminate) { @@ -75,7 +76,7 @@ SerializedTransaction::SerializedTransaction (SerializerIterator& sit) if ((length < Protocol::txMinSizeBytes) || (length > Protocol::txMaxSizeBytes)) { - WriteLog (lsERROR, SerializedTransaction) << + WriteLog (lsERROR, STTx) << "Transaction has invalid length: " << length; throw std::runtime_error ("Transaction length invalid"); } @@ -87,21 +88,21 @@ SerializedTransaction::SerializedTransaction (SerializerIterator& sit) if (!format) { - WriteLog (lsWARNING, SerializedTransaction) << + WriteLog (lsWARNING, STTx) << "Invalid transaction type: " << tx_type_; throw std::runtime_error ("invalid transaction type"); } if (!setType (format->elements)) { - WriteLog (lsWARNING, SerializedTransaction) << + WriteLog (lsWARNING, STTx) << "Transaction not legal for format"; throw std::runtime_error ("transaction not valid"); } } std::string -SerializedTransaction::getFullText () const +STTx::getFullText () const { std::string ret = "\""; ret += to_string (getTransactionID ()); @@ -112,7 +113,7 @@ SerializedTransaction::getFullText () const } std::vector -SerializedTransaction::getMentionedAccounts () const +STTx::getMentionedAccounts () const { std::vector accounts; @@ -144,18 +145,18 @@ SerializedTransaction::getMentionedAccounts () const } uint256 -SerializedTransaction::getSigningHash () const +STTx::getSigningHash () const { return STObject::getSigningHash (HashPrefix::txSign); } uint256 -SerializedTransaction::getTransactionID () const +STTx::getTransactionID () const { return getHash (HashPrefix::transactionID); } -Blob SerializedTransaction::getSignature () const +Blob STTx::getSignature () const { try { @@ -167,14 +168,14 @@ Blob SerializedTransaction::getSignature () const } } -void SerializedTransaction::sign (RippleAddress const& private_key) +void STTx::sign (RippleAddress const& private_key) { Blob signature; private_key.accountPrivateSign (getSigningHash (), signature); setFieldVL (sfTxnSignature, signature); } -bool SerializedTransaction::checkSign () const +bool STTx::checkSign () const { if (boost::indeterminate (sig_state_)) { @@ -196,7 +197,7 @@ bool SerializedTransaction::checkSign () const return static_cast (sig_state_); } -bool SerializedTransaction::checkSign (RippleAddress const& public_key) const +bool STTx::checkSign (RippleAddress const& public_key) const { try { @@ -213,24 +214,24 @@ bool SerializedTransaction::checkSign (RippleAddress const& public_key) const } } -void SerializedTransaction::setSigningPubKey (RippleAddress const& naSignPubKey) +void STTx::setSigningPubKey (RippleAddress const& naSignPubKey) { setFieldVL (sfSigningPubKey, naSignPubKey.getAccountPublic ()); } -void SerializedTransaction::setSourceAccount (RippleAddress const& naSource) +void STTx::setSourceAccount (RippleAddress const& naSource) { setFieldAccount (sfAccount, naSource); } -Json::Value SerializedTransaction::getJson (int) const +Json::Value STTx::getJson (int) const { Json::Value ret = STObject::getJson (0); ret["hash"] = to_string (getTransactionID ()); return ret; } -Json::Value SerializedTransaction::getJson (int options, bool binary) const +Json::Value STTx::getJson (int options, bool binary) const { if (binary) { @@ -244,7 +245,7 @@ Json::Value SerializedTransaction::getJson (int options, bool binary) const } std::string const& -SerializedTransaction::getMetaSQLInsertReplaceHeader () +STTx::getMetaSQLInsertReplaceHeader () { static std::string const sql = "INSERT OR REPLACE INTO Transactions " "(TransID, TransType, FromAcct, FromSeq, LedgerSeq, Status, RawTxn, TxnMeta)" @@ -253,7 +254,7 @@ SerializedTransaction::getMetaSQLInsertReplaceHeader () return sql; } -std::string SerializedTransaction::getMetaSQL (std::uint32_t inLedger, +std::string STTx::getMetaSQL (std::uint32_t inLedger, std::string const& escapedMetaData) const { Serializer s; @@ -262,7 +263,7 @@ std::string SerializedTransaction::getMetaSQL (std::uint32_t inLedger, } std::string -SerializedTransaction::getMetaSQL (Serializer rawTxn, +STTx::getMetaSQL (Serializer rawTxn, std::uint32_t inLedger, char status, std::string const& escapedMetaData) const { static boost::format bfTrans ("('%s', '%s', '%s', '%d', '%d', '%c', %s, %s)"); @@ -363,7 +364,7 @@ bool passesLocalChecks (STObject const& st) //------------------------------------------------------------------------------ -class SerializedTransaction_test : public beast::unit_test::suite +class STTx_test : public beast::unit_test::suite { public: void run() @@ -374,7 +375,7 @@ public: RippleAddress publicAcct = RippleAddress::createAccountPublic (generator, 1); RippleAddress privateAcct = RippleAddress::createAccountPrivate (generator, seed, 1); - SerializedTransaction j (ttACCOUNT_SET); + STTx j (ttACCOUNT_SET); j.setSourceAccount (publicAcct); j.setSigningPubKey (publicAcct); j.setFieldVL (sfMessageKey, publicAcct.getAccountPublic ()); @@ -385,7 +386,7 @@ public: Serializer rawTxn; j.add (rawTxn); SerializerIterator sit (rawTxn); - SerializedTransaction copy (sit); + STTx copy (sit); if (copy != j) { @@ -417,6 +418,6 @@ public: } }; -BEAST_DEFINE_TESTSUITE(SerializedTransaction,ripple_app,ripple); +BEAST_DEFINE_TESTSUITE(STTx,ripple_app,ripple); } // ripple diff --git a/src/ripple/app/ledger/SerializedValidation.cpp b/src/ripple/protocol/impl/STValidation.cpp similarity index 83% rename from src/ripple/app/ledger/SerializedValidation.cpp rename to src/ripple/protocol/impl/STValidation.cpp index a0b8ff73a3..5080d4670f 100644 --- a/src/ripple/app/ledger/SerializedValidation.cpp +++ b/src/ripple/protocol/impl/STValidation.cpp @@ -18,11 +18,12 @@ //============================================================================== #include +#include #include namespace ripple { -SerializedValidation::SerializedValidation (SerializerIterator& sit, bool checkSignature) +STValidation::STValidation (SerializerIterator& sit, bool checkSignature) : STObject (getFormat (), sit, sfValidation) , mTrusted (false) { @@ -36,7 +37,7 @@ SerializedValidation::SerializedValidation (SerializerIterator& sit, bool checkS } } -SerializedValidation::SerializedValidation ( +STValidation::STValidation ( uint256 const& ledgerHash, std::uint32_t signTime, RippleAddress const& raPub, bool isFull) : STObject (getFormat (), sfValidation) @@ -54,13 +55,13 @@ SerializedValidation::SerializedValidation ( setFlag (kFullFlag); } -void SerializedValidation::sign (RippleAddress const& raPriv) +void STValidation::sign (RippleAddress const& raPriv) { uint256 signingHash; sign (signingHash, raPriv); } -void SerializedValidation::sign (uint256& signingHash, RippleAddress const& raPriv) +void STValidation::sign (uint256& signingHash, RippleAddress const& raPriv) { setFlag (vfFullyCanonicalSig); @@ -70,32 +71,32 @@ void SerializedValidation::sign (uint256& signingHash, RippleAddress const& raPr setFieldVL (sfSignature, signature); } -uint256 SerializedValidation::getSigningHash () const +uint256 STValidation::getSigningHash () const { return STObject::getSigningHash (HashPrefix::validation); } -uint256 SerializedValidation::getLedgerHash () const +uint256 STValidation::getLedgerHash () const { return getFieldH256 (sfLedgerHash); } -std::uint32_t SerializedValidation::getSignTime () const +std::uint32_t STValidation::getSignTime () const { return getFieldU32 (sfSigningTime); } -std::uint32_t SerializedValidation::getFlags () const +std::uint32_t STValidation::getFlags () const { return getFieldU32 (sfFlags); } -bool SerializedValidation::isValid () const +bool STValidation::isValid () const { return isValid (getSigningHash ()); } -bool SerializedValidation::isValid (uint256 const& signingHash) const +bool STValidation::isValid (uint256 const& signingHash) const { try { @@ -112,31 +113,31 @@ bool SerializedValidation::isValid (uint256 const& signingHash) const } } -RippleAddress SerializedValidation::getSignerPublic () const +RippleAddress STValidation::getSignerPublic () const { RippleAddress a; a.setNodePublic (getFieldVL (sfSigningPubKey)); return a; } -bool SerializedValidation::isFull () const +bool STValidation::isFull () const { return (getFlags () & kFullFlag) != 0; } -Blob SerializedValidation::getSignature () const +Blob STValidation::getSignature () const { return getFieldVL (sfSignature); } -Blob SerializedValidation::getSigned () const +Blob STValidation::getSigned () const { Serializer s; add (s); return s.peekData (); } -SOTemplate const& SerializedValidation::getFormat () +SOTemplate const& STValidation::getFormat () { struct FormatHolder { diff --git a/src/ripple/protocol/impl/STVector256.cpp b/src/ripple/protocol/impl/STVector256.cpp new file mode 100644 index 0000000000..f7f4dc7528 --- /dev/null +++ b/src/ripple/protocol/impl/STVector256.cpp @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +/* + 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 +#include +#include +#include +#include + +namespace ripple { + +const STAmount saZero (noIssue(), 0u); +const STAmount saOne (noIssue(), 1u); + +// +// STVector256 +// + +// Return a new object from a SerializerIterator. +STVector256* STVector256::construct (SerializerIterator& u, SField::ref name) +{ + Blob data = u.getVL (); + Blob ::iterator begin = data.begin (); + + std::unique_ptr vec (new STVector256 (name)); + + int count = data.size () / (256 / 8); + vec->mValue.reserve (count); + + unsigned int uStart = 0; + + for (unsigned int i = 0; i != count; i++) + { + unsigned int uEnd = uStart + (256 / 8); + + // This next line could be optimized to construct a default uint256 in the vector and then copy into it + vec->mValue.push_back (uint256 (Blob (begin + uStart, begin + uEnd))); + uStart = uEnd; + } + + return vec.release (); +} + +void STVector256::add (Serializer& s) const +{ + assert (fName->isBinary ()); + assert (fName->fieldType == STI_VECTOR256); + s.addVL (mValue.empty () ? nullptr : mValue[0].begin (), mValue.size () * (256 / 8)); +} + +bool STVector256::isEquivalent (const STBase& t) const +{ + const STVector256* v = dynamic_cast (&t); + return v && (mValue == v->mValue); +} + +Json::Value STVector256::getJson (int) const +{ + Json::Value ret (Json::arrayValue); + + for (auto const& vEntry : mValue) + ret.append (to_string (vEntry)); + + return ret; +} + +} // ripple diff --git a/src/ripple/types/impl/UintTypes.cpp b/src/ripple/protocol/impl/UintTypes.cpp similarity index 98% rename from src/ripple/types/impl/UintTypes.cpp rename to src/ripple/protocol/impl/UintTypes.cpp index 0560a0215f..929e765dd5 100644 --- a/src/ripple/types/impl/UintTypes.cpp +++ b/src/ripple/protocol/impl/UintTypes.cpp @@ -17,10 +17,8 @@ */ //============================================================================== -#include - #include -#include +#include namespace ripple { diff --git a/src/ripple/rpc/handlers/LogLevel.cpp b/src/ripple/rpc/handlers/LogLevel.cpp index 32b5af5905..6c7ef1999f 100644 --- a/src/ripple/rpc/handlers/LogLevel.cpp +++ b/src/ripple/rpc/handlers/LogLevel.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include namespace ripple { diff --git a/src/ripple/rpc/handlers/Submit.cpp b/src/ripple/rpc/handlers/Submit.cpp index f931f2d8aa..1e632cf945 100644 --- a/src/ripple/rpc/handlers/Submit.cpp +++ b/src/ripple/rpc/handlers/Submit.cpp @@ -48,11 +48,11 @@ Json::Value doSubmit (RPC::Context& context) Serializer sTrans (ret.first); SerializerIterator sitTrans (sTrans); - SerializedTransaction::pointer stpTrans; + STTx::pointer stpTrans; try { - stpTrans = std::make_shared (std::ref (sitTrans)); + stpTrans = std::make_shared (std::ref (sitTrans)); } catch (std::exception& e) { diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index b891151b8f..9993fea2dc 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -337,11 +337,11 @@ transactionSign ( sfSigningPubKey, masterAccountPublic.getAccountPublic ()); - SerializedTransaction::pointer stpTrans; + STTx::pointer stpTrans; try { - stpTrans = std::make_shared (*sopTrans); + stpTrans = std::make_shared (*sopTrans); } catch (std::exception&) { diff --git a/src/ripple/types/AgedHistory.h b/src/ripple/types/AgedHistory.h deleted file mode 100644 index 08a6d83f5c..0000000000 --- a/src/ripple/types/AgedHistory.h +++ /dev/null @@ -1,74 +0,0 @@ -//------------------------------------------------------------------------------ -/* - 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. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_AGEDHISTORY_H_INCLUDED -#define RIPPLE_TYPES_AGEDHISTORY_H_INCLUDED - -namespace ripple { - -// Simple container swapping template -template -class AgedHistory -{ -public: - typedef Container container_type; - - AgedHistory() - : m_p1 (&m_c1) - , m_p2 (&m_c2) - { - } - - AgedHistory (AgedHistory const& other) - : m_c1 (other.front()) - , m_c2 (other.back()) - , m_p1 (&m_c1) - , m_p2 (&m_c2) - { - } - - AgedHistory& operator= (AgedHistory const& other) - { - m_c1 = other.front(); - m_c2 = other.back(); - m_p1 = &m_c1; - m_p2 = &m_c2; - return *this; - } - - void swap () { std::swap (m_p1, m_p2); } - - Container* operator-> () { return m_p1; } - Container const* operator-> () const { return m_p1; } - - Container& front() { return *m_p1; } - Container const& front() const { return *m_p1; } - Container& back() { return *m_p2; } - Container const& back() const { return *m_p2; } - -private: - Container m_c1; - Container m_c2; - Container* m_p1; - Container* m_p2; -}; - -} - -#endif diff --git a/src/ripple/types/ByteOrder.h b/src/ripple/types/ByteOrder.h index ff6f11593d..6a097ac9fe 100644 --- a/src/ripple/types/ByteOrder.h +++ b/src/ripple/types/ByteOrder.h @@ -20,6 +20,18 @@ #ifndef RIPPLE_TYPES_BYTEORDER_H #define RIPPLE_TYPES_BYTEORDER_H +#include + +// For ByteOrder +#if BEAST_WIN32 +// (nothing) +#elif __APPLE__ +#include +#elif defined(__FreeBSD__) || defined(__NetBSD__) +#include +#elif defined(__OpenBSD__) +#include +#endif #include namespace ripple { diff --git a/src/ripple/types/Issue.h b/src/ripple/types/Issue.h index e005885bc5..2d8e1802e5 100644 --- a/src/ripple/types/Issue.h +++ b/src/ripple/types/Issue.h @@ -24,7 +24,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/types/impl/ByteOrder.cpp b/src/ripple/types/impl/ByteOrder.cpp index 669384b4f0..8619dce899 100644 --- a/src/ripple/types/impl/ByteOrder.cpp +++ b/src/ripple/types/impl/ByteOrder.cpp @@ -17,6 +17,17 @@ */ //============================================================================== +#ifdef BEAST_WIN32 +#include +// defines min, max and does other stupid things +# ifdef max +# undef max +# endif +# ifdef min +# undef min +# endif +#endif + namespace ripple { #if BEAST_WIN32 diff --git a/src/ripple/types/impl/Issue.cpp b/src/ripple/types/impl/Issue.cpp index 129e4e4d9f..3359a72d64 100644 --- a/src/ripple/types/impl/Issue.cpp +++ b/src/ripple/types/impl/Issue.cpp @@ -18,9 +18,10 @@ //============================================================================== #include - +#include +#include #include - +#include #include #include #include diff --git a/src/ripple/unity/app.h b/src/ripple/unity/app.h index 089042f4d9..a9ffae090e 100644 --- a/src/ripple/unity/app.h +++ b/src/ripple/unity/app.h @@ -24,27 +24,6 @@ #include #endif -// VFALCO TODO Reduce these boost dependencies. Make more interfaces -// purely abstract and move implementation into .cpp files. -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------------------------ - -#include - #include // VFALCO TODO Remove this include @@ -62,20 +41,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include #include #include -#include #include #include #include diff --git a/src/ripple/unity/app1.cpp b/src/ripple/unity/app1.cpp index 745286f1bc..0e3d45505b 100644 --- a/src/ripple/unity/app1.cpp +++ b/src/ripple/unity/app1.cpp @@ -19,13 +19,10 @@ #include -#include - #include #include #include #include -#include #include #include #include diff --git a/src/ripple/unity/app7.cpp b/src/ripple/unity/app7.cpp index a533f00ea0..b98b1856b1 100644 --- a/src/ripple/unity/app7.cpp +++ b/src/ripple/unity/app7.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/src/ripple/unity/app8.cpp b/src/ripple/unity/app8.cpp index 1ba9cd63b4..ea1ad59da3 100644 --- a/src/ripple/unity/app8.cpp +++ b/src/ripple/unity/app8.cpp @@ -43,7 +43,6 @@ #include #include -#include #ifdef _MSC_VER #pragma warning (pop) diff --git a/src/ripple/unity/protocol.cpp b/src/ripple/unity/protocol.cpp index 19433933bd..fac07dec20 100644 --- a/src/ripple/unity/protocol.cpp +++ b/src/ripple/unity/protocol.cpp @@ -29,14 +29,25 @@ #include #include #include -#include -#include #include -#include -#include -#include +#include #include #include +#include + +#include +#include #include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include + +// VFALCO Should be in a tests dir +#include diff --git a/src/ripple/unity/types.cpp b/src/ripple/unity/types.cpp index f2ce041f28..f5834592a2 100644 --- a/src/ripple/unity/types.cpp +++ b/src/ripple/unity/types.cpp @@ -19,25 +19,8 @@ #include -#include - -#ifdef BEAST_WIN32 -#include // for ByteOrder.cpp -// defines min, max and does other stupid things -# ifdef max -# undef max -# endif -# ifdef min -# undef min -# endif -#endif - -#include -#include - #include #include #include -#include #include #include diff --git a/src/ripple/unity/types.h b/src/ripple/unity/types.h deleted file mode 100644 index 26aee9c25e..0000000000 --- a/src/ripple/unity/types.h +++ /dev/null @@ -1,61 +0,0 @@ -//------------------------------------------------------------------------------ -/* - 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. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_H_INCLUDED -#define RIPPLE_TYPES_H_INCLUDED - -#include - -#include - -#include -#include - -// For ByteOrder -#if BEAST_WIN32 -// (nothing) -#elif __APPLE__ -#include -#elif defined(__FreeBSD__) || defined(__NetBSD__) -#include -#elif defined(__OpenBSD__) -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif