diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj index 14bac284f5..05afef861e 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj +++ b/Builds/VisualStudio2012/RippleD.vcxproj @@ -847,12 +847,6 @@ true true - - true - true - true - true - true true @@ -1636,7 +1630,6 @@ - diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters index 55195202c4..0d268090ba 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters @@ -549,9 +549,6 @@ 1. Modules\ripple_app\refactored\pathing - - 1. Modules\ripple_data\protocol - 1. Modules\ripple_data\protocol @@ -1394,9 +1391,6 @@ 1. Modules\ripple_data\protocol - - 1. Modules\ripple_data\protocol - 1. Modules\ripple_data\protocol @@ -1794,6 +1788,7 @@ 1. Modules\ripple_app\basics + diff --git a/TODO.txt b/TODO.txt index 34c620ba59..a168f5f9af 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,14 +2,13 @@ TODO -------------------------------------------------------------------------------- +- Replace all NULL with nullptr + - Make beast::HashMap support assignment via operator[] - Rewrite TxFormats to use beast containers and RAII, and not leak - Add ICore interface - Make TxFormats a member of ICore instead of a singleton. -- Allow manual string labels for LogPartition, to fix the problem where - the log partition gets a file name like "ripple_LedgerConsensus" - - Rename LoadMonitor to LoadMeter, change LoadEvent to LoadMeter::ScopedSample - Rewrite every beast Doxygen comment, update Beast Doxyfile diff --git a/modules/ripple_data/protocol/ripple_LedgerFormat.h b/modules/ripple_data/protocol/ripple_LedgerFormat.h index eb8e0f4a8f..7547c11795 100644 --- a/modules/ripple_data/protocol/ripple_LedgerFormat.h +++ b/modules/ripple_data/protocol/ripple_LedgerFormat.h @@ -97,7 +97,7 @@ enum LedgerSpecificFlags lsfHighAuth = 0x00080000, }; -// VFALCO TODO See if we can merge LedgerEntryFormat with TxFormat +// VFALCO TODO See if we can merge LedgerEntryFormat with TxFormats // class LedgerEntryFormat { diff --git a/modules/ripple_data/protocol/ripple_SerializedObject.cpp b/modules/ripple_data/protocol/ripple_SerializedObject.cpp index 496054e713..587882ac0c 100644 --- a/modules/ripple_data/protocol/ripple_SerializedObject.cpp +++ b/modules/ripple_data/protocol/ripple_SerializedObject.cpp @@ -1269,12 +1269,10 @@ UPTR_T STObject::parseJson (const Json::Value& object, SField::ref inN { if (field == sfTransactionType) { - TxFormat* f = TxFormats::getInstance ().findByName (strValue); + // Retrieve type from name. Throws if not found. + TxType const txType = TxFormats::getInstance().findTypeByName (strValue); - if (!f) - throw std::runtime_error ("Unknown transaction type"); - - data.push_back (new STUInt16 (field, static_cast (f->getType ()))); + data.push_back (new STUInt16 (field, static_cast (txType))); if (*name == sfGeneric) name = &sfTransaction; diff --git a/modules/ripple_data/protocol/ripple_SerializedTypes.cpp b/modules/ripple_data/protocol/ripple_SerializedTypes.cpp index 43ae0bbbad..189502971d 100644 --- a/modules/ripple_data/protocol/ripple_SerializedTypes.cpp +++ b/modules/ripple_data/protocol/ripple_SerializedTypes.cpp @@ -129,7 +129,7 @@ std::string STUInt16::getText () const if (getFName () == sfTransactionType) { - TxFormat* f = TxFormats::getInstance ().findByType (static_cast (value)); + TxFormats::Item const* f = TxFormats::getInstance().findByType (static_cast (value)); if (f != NULL) return f->getName (); @@ -150,7 +150,7 @@ Json::Value STUInt16::getJson (int) const if (getFName () == sfTransactionType) { - TxFormat* f = TxFormats::getInstance ().findByType (static_cast (value)); + TxFormats::Item const* f = TxFormats::getInstance().findByType (static_cast (value)); if (f != NULL) return f->getName (); diff --git a/modules/ripple_data/protocol/ripple_TxFormat.cpp b/modules/ripple_data/protocol/ripple_TxFormat.cpp deleted file mode 100644 index 49eee8679b..0000000000 --- a/modules/ripple_data/protocol/ripple_TxFormat.cpp +++ /dev/null @@ -1,93 +0,0 @@ -//------------------------------------------------------------------------------ -/* - Copyright (c) 2011-2013, OpenCoin, Inc. -*/ -//============================================================================== - -// VFALCO TODO Find a way to not use macros. inline function? - -#define TF_BASE \ - << SOElement(sfTransactionType, SOE_REQUIRED) \ - << SOElement(sfFlags, SOE_OPTIONAL) \ - << SOElement(sfSourceTag, SOE_OPTIONAL) \ - << SOElement(sfAccount, SOE_REQUIRED) \ - << SOElement(sfSequence, SOE_REQUIRED) \ - << SOElement(sfPreviousTxnID, SOE_OPTIONAL) \ - << SOElement(sfFee, SOE_REQUIRED) \ - << SOElement(sfOperationLimit, SOE_OPTIONAL) \ - << SOElement(sfSigningPubKey, SOE_REQUIRED) \ - << SOElement(sfTxnSignature, SOE_OPTIONAL) - -#define DECLARE_TF(name, type) tf = TxFormats::getInstance().add (new TxFormat(#name, type)); (*tf) TF_BASE - -void TFInit () -{ - TxFormat* tf; - - DECLARE_TF (AccountSet, ttACCOUNT_SET) - << SOElement (sfEmailHash, SOE_OPTIONAL) - << SOElement (sfWalletLocator, SOE_OPTIONAL) - << SOElement (sfWalletSize, SOE_OPTIONAL) - << SOElement (sfMessageKey, SOE_OPTIONAL) - << SOElement (sfDomain, SOE_OPTIONAL) - << SOElement (sfTransferRate, SOE_OPTIONAL) - << SOElement (sfSetFlag, SOE_OPTIONAL) - << SOElement (sfClearFlag, SOE_OPTIONAL) - ; - - DECLARE_TF (TrustSet, ttTRUST_SET) - << SOElement (sfLimitAmount, SOE_OPTIONAL) - << SOElement (sfQualityIn, SOE_OPTIONAL) - << SOElement (sfQualityOut, SOE_OPTIONAL) - ; - - DECLARE_TF (OfferCreate, ttOFFER_CREATE) - << SOElement (sfTakerPays, SOE_REQUIRED) - << SOElement (sfTakerGets, SOE_REQUIRED) - << SOElement (sfExpiration, SOE_OPTIONAL) - << SOElement (sfOfferSequence, SOE_OPTIONAL) - ; - - DECLARE_TF (OfferCancel, ttOFFER_CANCEL) - << SOElement (sfOfferSequence, SOE_REQUIRED) - ; - - DECLARE_TF (SetRegularKey, ttREGULAR_KEY_SET) - << SOElement (sfRegularKey, SOE_OPTIONAL) - ; - - DECLARE_TF (Payment, ttPAYMENT) - << SOElement (sfDestination, SOE_REQUIRED) - << SOElement (sfAmount, SOE_REQUIRED) - << SOElement (sfSendMax, SOE_OPTIONAL) - << SOElement (sfPaths, SOE_DEFAULT) - << SOElement (sfInvoiceID, SOE_OPTIONAL) - << SOElement (sfDestinationTag, SOE_OPTIONAL) - ; - - DECLARE_TF (Contract, ttCONTRACT) - << SOElement (sfExpiration, SOE_REQUIRED) - << SOElement (sfBondAmount, SOE_REQUIRED) - << SOElement (sfStampEscrow, SOE_REQUIRED) - << SOElement (sfRippleEscrow, SOE_REQUIRED) - << SOElement (sfCreateCode, SOE_OPTIONAL) - << SOElement (sfFundCode, SOE_OPTIONAL) - << SOElement (sfRemoveCode, SOE_OPTIONAL) - << SOElement (sfExpireCode, SOE_OPTIONAL) - ; - - DECLARE_TF (RemoveContract, ttCONTRACT_REMOVE) - << SOElement (sfTarget, SOE_REQUIRED) - ; - - DECLARE_TF (EnableFeature, ttFEATURE) - << SOElement (sfFeature, SOE_REQUIRED) - ; - - DECLARE_TF (SetFee, ttFEE) - << SOElement (sfBaseFee, SOE_REQUIRED) - << SOElement (sfReferenceFeeUnits, SOE_REQUIRED) - << SOElement (sfReserveBase, SOE_REQUIRED) - << SOElement (sfReserveIncrement, SOE_REQUIRED) - ; -} diff --git a/modules/ripple_data/protocol/ripple_TxFormat.h b/modules/ripple_data/protocol/ripple_TxFormat.h deleted file mode 100644 index 09ff0ea2a2..0000000000 --- a/modules/ripple_data/protocol/ripple_TxFormat.h +++ /dev/null @@ -1,76 +0,0 @@ -//------------------------------------------------------------------------------ -/* - Copyright (c) 2011-2013, OpenCoin, Inc. -*/ -//============================================================================== - -#ifndef RIPPLE_TXFORMAT_H -#define RIPPLE_TXFORMAT_H - -// VFALCO TODO Rename to TxType -// Be aware there are some strings "TransactionType" -// And also we have TransactionType in ripple_SerializeDeclarations.h -// -/** Transaction type identifiers. - - These are part of the binary message format. - - @ingroup protocol -*/ -enum TransactionType -{ - ttINVALID = -1, - - ttPAYMENT = 0, - ttCLAIM = 1, // open - ttWALLET_ADD = 2, - ttACCOUNT_SET = 3, - ttPASSWORD_FUND = 4, // open - ttREGULAR_KEY_SET = 5, - ttNICKNAME_SET = 6, // open - ttOFFER_CREATE = 7, - ttOFFER_CANCEL = 8, - ttCONTRACT = 9, - ttCONTRACT_REMOVE = 10, // can we use the same msg as offer cancel - - ttTRUST_SET = 20, - - ttFEATURE = 100, - ttFEE = 101, -}; - -class TxFormat -{ -public: - TxFormat (char const* name, TransactionType type) - : m_name (name) - , m_type (type) - { - } - - TxFormat& operator<< (SOElement const& el) - { - elements.push_back (el); - - return *this; - } - - /** Retrieve the name of the format. - */ - std::string const& getName () const { return m_name; } - - /** Retrieve the transaction type this format represents. - */ - TransactionType getType () const { return m_type; } - -public: - // VFALCO TODO make an accessor for this - SOTemplate elements; - -private: - std::string const m_name; - TransactionType const m_type; -}; - -#endif -// vim:ts=4 diff --git a/modules/ripple_data/protocol/ripple_TxFormats.cpp b/modules/ripple_data/protocol/ripple_TxFormats.cpp index 14c248c21e..97e4d6c786 100644 --- a/modules/ripple_data/protocol/ripple_TxFormats.cpp +++ b/modules/ripple_data/protocol/ripple_TxFormats.cpp @@ -4,27 +4,143 @@ */ //============================================================================== -TxFormats& TxFormats::getInstance () +TxFormats::Item::Item (char const* name, TxType type) + : m_name (name) + , m_type (type) +{ +} + +TxFormats::Item& TxFormats::Item::operator<< (SOElement const& el) +{ + elements.push_back (el); + + return *this; +} + +std::string const& TxFormats::Item::getName () const noexcept +{ + return m_name; +} + +TxType TxFormats::Item::getType () const noexcept +{ + return m_type; +} + +//------------------------------------------------------------------------------ + +void TxFormats::addCommonFields (Item& item) +{ + item + << SOElement(sfTransactionType, SOE_REQUIRED) + << SOElement(sfFlags, SOE_OPTIONAL) + << SOElement(sfSourceTag, SOE_OPTIONAL) + << SOElement(sfAccount, SOE_REQUIRED) + << SOElement(sfSequence, SOE_REQUIRED) + << SOElement(sfPreviousTxnID, SOE_OPTIONAL) + << SOElement(sfFee, SOE_REQUIRED) + << SOElement(sfOperationLimit, SOE_OPTIONAL) + << SOElement(sfSigningPubKey, SOE_REQUIRED) + << SOElement(sfTxnSignature, SOE_OPTIONAL) + ; +} + +TxFormats::TxFormats () +{ + add ("AccountSet", ttACCOUNT_SET) + << SOElement (sfEmailHash, SOE_OPTIONAL) + << SOElement (sfWalletLocator, SOE_OPTIONAL) + << SOElement (sfWalletSize, SOE_OPTIONAL) + << SOElement (sfMessageKey, SOE_OPTIONAL) + << SOElement (sfDomain, SOE_OPTIONAL) + << SOElement (sfTransferRate, SOE_OPTIONAL) + << SOElement (sfSetFlag, SOE_OPTIONAL) + << SOElement (sfClearFlag, SOE_OPTIONAL) + ; + + add ("TrustSet", ttTRUST_SET) + << SOElement (sfLimitAmount, SOE_OPTIONAL) + << SOElement (sfQualityIn, SOE_OPTIONAL) + << SOElement (sfQualityOut, SOE_OPTIONAL) + ; + + add ("OfferCreate", ttOFFER_CREATE) + << SOElement (sfTakerPays, SOE_REQUIRED) + << SOElement (sfTakerGets, SOE_REQUIRED) + << SOElement (sfExpiration, SOE_OPTIONAL) + << SOElement (sfOfferSequence, SOE_OPTIONAL) + ; + + add ("OfferCancel", ttOFFER_CANCEL) + << SOElement (sfOfferSequence, SOE_REQUIRED) + ; + + add ("SetRegularKey", ttREGULAR_KEY_SET) + << SOElement (sfRegularKey, SOE_OPTIONAL) + ; + + add ("Payment", ttPAYMENT) + << SOElement (sfDestination, SOE_REQUIRED) + << SOElement (sfAmount, SOE_REQUIRED) + << SOElement (sfSendMax, SOE_OPTIONAL) + << SOElement (sfPaths, SOE_DEFAULT) + << SOElement (sfInvoiceID, SOE_OPTIONAL) + << SOElement (sfDestinationTag, SOE_OPTIONAL) + ; + + add ("Contract", ttCONTRACT) + << SOElement (sfExpiration, SOE_REQUIRED) + << SOElement (sfBondAmount, SOE_REQUIRED) + << SOElement (sfStampEscrow, SOE_REQUIRED) + << SOElement (sfRippleEscrow, SOE_REQUIRED) + << SOElement (sfCreateCode, SOE_OPTIONAL) + << SOElement (sfFundCode, SOE_OPTIONAL) + << SOElement (sfRemoveCode, SOE_OPTIONAL) + << SOElement (sfExpireCode, SOE_OPTIONAL) + ; + + add ("RemoveContract", ttCONTRACT_REMOVE) + << SOElement (sfTarget, SOE_REQUIRED) + ; + + add ("EnableFeature", ttFEATURE) + << SOElement (sfFeature, SOE_REQUIRED) + ; + + add ("SetFee", ttFEE) + << SOElement (sfBaseFee, SOE_REQUIRED) + << SOElement (sfReferenceFeeUnits, SOE_REQUIRED) + << SOElement (sfReserveBase, SOE_REQUIRED) + << SOElement (sfReserveIncrement, SOE_REQUIRED) + ; +} + +TxFormats const& TxFormats::getInstance () { static TxFormats instance; return instance; } -TxFormat* TxFormats::add (TxFormat* txFormat) +TxType TxFormats::findTypeByName (std::string const name) const { - // VFALCO TODO Figure out when and how to delete the TxFormat objects later? - m_types [txFormat->getType ()] = txFormat; - m_names [txFormat->getName ()] = txFormat; + Item const* const result = findByName (name); - return txFormat; + if (result != nullptr) + { + return result->getType (); + } + else + { + throw std::runtime_error ("Unknown format name"); + } } -TxFormat* TxFormats::findByType (TransactionType type) +TxFormats::Item const* TxFormats::findByType (TxType type) const noexcept { - TxFormat* result = NULL; + Item* result = nullptr; - TypeMap::iterator const iter = m_types.find (type); + TypeMap::const_iterator const iter = m_types.find (type); if (iter != m_types.end ()) { @@ -34,11 +150,11 @@ TxFormat* TxFormats::findByType (TransactionType type) return result; } -TxFormat* TxFormats::findByName (std::string const& name) +TxFormats::Item const* TxFormats::findByName (std::string const& name) const noexcept { - TxFormat* result = NULL; // VFALCO TODO replace all NULL with nullptr + Item* result = nullptr; - NameMap::iterator const iter = m_names.find (name); + NameMap::const_iterator const iter = m_names.find (name); if (iter != m_names.end ()) { @@ -48,7 +164,14 @@ TxFormat* TxFormats::findByName (std::string const& name) return result; } -TxFormats::TxFormats () +TxFormats::Item& TxFormats::add (char const* name, TxType type) { -} + Item& item = m_formats.add (new Item (name, type)); + addCommonFields (item); + + m_types [item.getType ()] = &item; + m_names [item.getName ()] = &item; + + return item; +} diff --git a/modules/ripple_data/protocol/ripple_TxFormats.h b/modules/ripple_data/protocol/ripple_TxFormats.h index 12878db2ab..42e1e42859 100644 --- a/modules/ripple_data/protocol/ripple_TxFormats.h +++ b/modules/ripple_data/protocol/ripple_TxFormats.h @@ -4,43 +4,119 @@ */ //============================================================================== -#ifndef RIPPLE_TXFORMATS_H -#define RIPPLE_TXFORMATS_H +#ifndef RIPPLE_TXFORMATS_H_INCLUDED +#define RIPPLE_TXFORMATS_H_INCLUDED + +/** Transaction type identifiers. + + These are part of the binary message format. + + @ingroup protocol +*/ +enum TxType +{ + ttINVALID = -1, + + ttPAYMENT = 0, + ttCLAIM = 1, // open + ttWALLET_ADD = 2, + ttACCOUNT_SET = 3, + ttPASSWORD_FUND = 4, // open + ttREGULAR_KEY_SET = 5, + ttNICKNAME_SET = 6, // open + ttOFFER_CREATE = 7, + ttOFFER_CANCEL = 8, + ttCONTRACT = 9, + ttCONTRACT_REMOVE = 10, // can we use the same msg as offer cancel + + ttTRUST_SET = 20, + + ttFEATURE = 100, + ttFEE = 101, +}; /** Manages the list of known transaction formats. */ class TxFormats { public: - // VFALCO TODO Make this a member of the Application object instead of a singleton? - static TxFormats& getInstance (); - - /** Add a format. - - The caller is responsible for freeing the memory. - - @return The passed format. + /** A transaction format. */ - TxFormat* add (TxFormat* txFormat); + class Item + { + public: + Item (char const* name, TxType type); + + Item& operator<< (SOElement const& el); + + /** Retrieve the name of the format. + */ + std::string const& getName () const noexcept; + + /** Retrieve the transaction type this format represents. + */ + TxType getType () const noexcept; + + public: + // VFALCO TODO make an accessor for this + SOTemplate elements; + + private: + std::string const m_name; + TxType const m_type; + }; + +private: + /** Create the object. + + This will load the object will all the known transaction formats. + */ + TxFormats (); + + static void addCommonFields (Item& item); + +public: + /** Retrieve the global instance. + */ + static TxFormats const& getInstance (); + + /** Retrieve the type for a transaction format specified by name. + + If the format name is unknown, an exception is thrown. + + @param name The name of the transaction type. + @return The transaction type. + */ + TxType findTypeByName (std::string const name) const; /** Retrieve a format based on its transaction type. */ - TxFormat* findByType (TransactionType type); + Item const* findByType (TxType type) const noexcept; /** Retrieve a format based on its name. */ - TxFormat* findByName (std::string const& name); + Item const* findByName (std::string const& name) const noexcept; + +protected: + /** Add a new format. + + The new format has the set of common fields already added. + + @param name The name of this format. + @param type The transaction type of this format. + + @return The created format. + */ + Item& add (char const* name, TxType type); private: - TxFormats (); - -private: - typedef std::map NameMap; - typedef std::map TypeMap; + // VFALCO TODO use String instead of std::string + typedef std::map NameMap; + typedef std::map TypeMap; + OwnedArray m_formats; NameMap m_names; TypeMap m_types; }; #endif -// vim:ts=4 diff --git a/modules/ripple_data/ripple_data.cpp b/modules/ripple_data/ripple_data.cpp index 516652b179..72dcb022a8 100644 --- a/modules/ripple_data/ripple_data.cpp +++ b/modules/ripple_data/ripple_data.cpp @@ -79,7 +79,6 @@ namespace ripple #include "protocol/ripple_SerializedObjectTemplate.cpp" #include "protocol/ripple_SerializedObject.cpp" #include "protocol/ripple_TER.cpp" -#include "protocol/ripple_TxFormat.cpp" #include "protocol/ripple_TxFormats.cpp" // These are for STAmount diff --git a/modules/ripple_data/ripple_data.h b/modules/ripple_data/ripple_data.h index 80851a40d5..f7119de17e 100644 --- a/modules/ripple_data/ripple_data.h +++ b/modules/ripple_data/ripple_data.h @@ -50,7 +50,6 @@ namespace ripple #include "protocol/ripple_SerializedObject.h" #include "protocol/ripple_LedgerFormat.h" // needs SOTemplate from SerializedObject #include "protocol/ripple_TxFlags.h" -#include "protocol/ripple_TxFormat.h" #include "protocol/ripple_TxFormats.h" #include "utility/ripple_UptimeTimerAdapter.h" diff --git a/src/cpp/ripple/Transaction.cpp b/src/cpp/ripple/Transaction.cpp index eedcafdb17..e60824c98d 100644 --- a/src/cpp/ripple/Transaction.cpp +++ b/src/cpp/ripple/Transaction.cpp @@ -45,7 +45,7 @@ Transaction::pointer Transaction::sharedTransaction (Blob const& vucTransaction, // Transaction::Transaction ( - TransactionType ttKind, + TxType ttKind, const RippleAddress& naPublicKey, const RippleAddress& naSourceAccount, uint32 uSeq, diff --git a/src/cpp/ripple/Transaction.h b/src/cpp/ripple/Transaction.h index 66505c5a7b..6753836c44 100644 --- a/src/cpp/ripple/Transaction.h +++ b/src/cpp/ripple/Transaction.h @@ -44,7 +44,7 @@ public: static Transaction::pointer transactionFromSQL (Database * db, bool bValidate); Transaction ( - TransactionType ttKind, + TxType ttKind, const RippleAddress & naPublicKey, // To prove transaction is consistent and authorized. const RippleAddress & naSourceAccount, // To identify the paying account. uint32 uSeq, // To order transactions. diff --git a/src/cpp/ripple/main.cpp b/src/cpp/ripple/main.cpp index 0d5e1b23ac..ed1dac2efb 100644 --- a/src/cpp/ripple/main.cpp +++ b/src/cpp/ripple/main.cpp @@ -7,7 +7,6 @@ namespace po = boost::program_options; // VFALCO TODO make these singletons that initialize statically -extern void TFInit (); extern void LEFInit (); void setupServer () @@ -210,7 +209,6 @@ int rippleMain (int argc, char** argv) Log::setMinSeverity (lsINFO, true); // VFALCO TODO make these singletons that initialize statically - TFInit (); LEFInit (); if (vm.count ("unittest")) diff --git a/src/cpp/ripple/ripple_AcceptedLedgerTx.h b/src/cpp/ripple/ripple_AcceptedLedgerTx.h index 2b14f84547..f9a5137b20 100644 --- a/src/cpp/ripple/ripple_AcceptedLedgerTx.h +++ b/src/cpp/ripple/ripple_AcceptedLedgerTx.h @@ -56,7 +56,7 @@ public: { return mTxn->getTransactionID (); } - TransactionType getTxnType () const + TxType getTxnType () const { return mTxn->getTxnType (); } diff --git a/src/cpp/ripple/ripple_SerializedTransaction.cpp b/src/cpp/ripple/ripple_SerializedTransaction.cpp index 7116867480..1a227bf13d 100644 --- a/src/cpp/ripple/ripple_SerializedTransaction.cpp +++ b/src/cpp/ripple/ripple_SerializedTransaction.cpp @@ -6,15 +6,15 @@ SETUP_LOG (SerializedTransaction) -SerializedTransaction::SerializedTransaction (TransactionType type) +SerializedTransaction::SerializedTransaction (TxType type) : STObject (sfTransaction) , mType (type) , mSigGood (false) , mSigBad (false) { - mFormat = TxFormats::getInstance ().findByType (type); + mFormat = TxFormats::getInstance().findByType (type); - if (mFormat == NULL) + if (mFormat == nullptr) { WriteLog (lsWARNING, SerializedTransaction) << "Transaction type: " << type; throw std::runtime_error ("invalid transaction type"); @@ -29,9 +29,9 @@ SerializedTransaction::SerializedTransaction (STObject const& object) , mSigGood (false) , mSigBad (false) { - mType = static_cast (getFieldU16 (sfTransactionType)); + mType = static_cast (getFieldU16 (sfTransactionType)); - mFormat = TxFormats::getInstance ().findByType (mType); + mFormat = TxFormats::getInstance().findByType (mType); if (!mFormat) { @@ -57,9 +57,9 @@ SerializedTransaction::SerializedTransaction (SerializerIterator& sit) : STObjec } set (sit); - mType = static_cast (getFieldU16 (sfTransactionType)); + mType = static_cast (getFieldU16 (sfTransactionType)); - mFormat = TxFormats::getInstance ().findByType (mType); + mFormat = TxFormats::getInstance().findByType (mType); if (!mFormat) { diff --git a/src/cpp/ripple/ripple_SerializedTransaction.h b/src/cpp/ripple/ripple_SerializedTransaction.h index 7c2a8e3364..169c3753fc 100644 --- a/src/cpp/ripple/ripple_SerializedTransaction.h +++ b/src/cpp/ripple/ripple_SerializedTransaction.h @@ -28,7 +28,7 @@ public: public: SerializedTransaction (SerializerIterator & sit); - SerializedTransaction (TransactionType type); + SerializedTransaction (TxType type); SerializedTransaction (const STObject & object); // STObject functions @@ -47,7 +47,7 @@ public: } uint256 getSigningHash () const; - TransactionType getTxnType () const + TxType getTxnType () const { return mType; } @@ -127,8 +127,8 @@ public: std::string getMetaSQL (Serializer rawTxn, uint32 inLedger, char status, const std::string & escapedMetaData) const; private: - TransactionType mType; - const TxFormat* mFormat; + TxType mType; + TxFormats::Item const* mFormat; SerializedTransaction* duplicate () const {