mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Refactor TxFormats and fix leak on exit
This commit is contained in:
@@ -847,12 +847,6 @@
|
|||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_TxFormat.cpp">
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.cpp">
|
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
@@ -1636,7 +1630,6 @@
|
|||||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_Serializer.h" />
|
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_Serializer.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TER.h" />
|
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TER.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFlags.h" />
|
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFlags.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFormat.h" />
|
|
||||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.h" />
|
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_data\ripple_data.h" />
|
<ClInclude Include="..\..\modules\ripple_data\ripple_data.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_JSONCache.h" />
|
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_JSONCache.h" />
|
||||||
|
|||||||
@@ -549,9 +549,6 @@
|
|||||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_RippleCalc.cpp">
|
<ClCompile Include="..\..\src\cpp\ripple\ripple_RippleCalc.cpp">
|
||||||
<Filter>1. Modules\ripple_app\refactored\pathing</Filter>
|
<Filter>1. Modules\ripple_app\refactored\pathing</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_TxFormat.cpp">
|
|
||||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.cpp">
|
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.cpp">
|
||||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -1394,9 +1391,6 @@
|
|||||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_HashPrefix.h">
|
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_HashPrefix.h">
|
||||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFormat.h">
|
|
||||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_Protocol.h">
|
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_Protocol.h">
|
||||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -1794,6 +1788,7 @@
|
|||||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildVersion.h">
|
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildVersion.h">
|
||||||
<Filter>1. Modules\ripple_app\basics</Filter>
|
<Filter>1. Modules\ripple_app\basics</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_JSONCache.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\src\cpp\protobuf\src\google\protobuf\descriptor.proto">
|
<None Include="..\..\src\cpp\protobuf\src\google\protobuf\descriptor.proto">
|
||||||
|
|||||||
5
TODO.txt
5
TODO.txt
@@ -2,14 +2,13 @@
|
|||||||
TODO
|
TODO
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- Replace all NULL with nullptr
|
||||||
|
|
||||||
- Make beast::HashMap support assignment via operator[]
|
- Make beast::HashMap support assignment via operator[]
|
||||||
- Rewrite TxFormats to use beast containers and RAII, and not leak
|
- Rewrite TxFormats to use beast containers and RAII, and not leak
|
||||||
- Add ICore interface
|
- Add ICore interface
|
||||||
- Make TxFormats a member of ICore instead of a singleton.
|
- 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
|
- Rename LoadMonitor to LoadMeter, change LoadEvent to LoadMeter::ScopedSample
|
||||||
|
|
||||||
- Rewrite every beast Doxygen comment, update Beast Doxyfile
|
- Rewrite every beast Doxygen comment, update Beast Doxyfile
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ enum LedgerSpecificFlags
|
|||||||
lsfHighAuth = 0x00080000,
|
lsfHighAuth = 0x00080000,
|
||||||
};
|
};
|
||||||
|
|
||||||
// VFALCO TODO See if we can merge LedgerEntryFormat with TxFormat
|
// VFALCO TODO See if we can merge LedgerEntryFormat with TxFormats
|
||||||
//
|
//
|
||||||
class LedgerEntryFormat
|
class LedgerEntryFormat
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1269,12 +1269,10 @@ UPTR_T<STObject> STObject::parseJson (const Json::Value& object, SField::ref inN
|
|||||||
{
|
{
|
||||||
if (field == sfTransactionType)
|
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)
|
data.push_back (new STUInt16 (field, static_cast<uint16> (txType)));
|
||||||
throw std::runtime_error ("Unknown transaction type");
|
|
||||||
|
|
||||||
data.push_back (new STUInt16 (field, static_cast<uint16> (f->getType ())));
|
|
||||||
|
|
||||||
if (*name == sfGeneric)
|
if (*name == sfGeneric)
|
||||||
name = &sfTransaction;
|
name = &sfTransaction;
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ std::string STUInt16::getText () const
|
|||||||
|
|
||||||
if (getFName () == sfTransactionType)
|
if (getFName () == sfTransactionType)
|
||||||
{
|
{
|
||||||
TxFormat* f = TxFormats::getInstance ().findByType (static_cast <TransactionType> (value));
|
TxFormats::Item const* f = TxFormats::getInstance().findByType (static_cast <TxType> (value));
|
||||||
|
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
return f->getName ();
|
return f->getName ();
|
||||||
@@ -150,7 +150,7 @@ Json::Value STUInt16::getJson (int) const
|
|||||||
|
|
||||||
if (getFName () == sfTransactionType)
|
if (getFName () == sfTransactionType)
|
||||||
{
|
{
|
||||||
TxFormat* f = TxFormats::getInstance ().findByType (static_cast <TransactionType> (value));
|
TxFormats::Item const* f = TxFormats::getInstance().findByType (static_cast <TxType> (value));
|
||||||
|
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
return f->getName ();
|
return f->getName ();
|
||||||
|
|||||||
@@ -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)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
@@ -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;
|
static TxFormats instance;
|
||||||
|
|
||||||
return 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?
|
Item const* const result = findByName (name);
|
||||||
m_types [txFormat->getType ()] = txFormat;
|
|
||||||
m_names [txFormat->getName ()] = txFormat;
|
|
||||||
|
|
||||||
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 ())
|
if (iter != m_types.end ())
|
||||||
{
|
{
|
||||||
@@ -34,11 +150,11 @@ TxFormat* TxFormats::findByType (TransactionType type)
|
|||||||
return result;
|
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 ())
|
if (iter != m_names.end ())
|
||||||
{
|
{
|
||||||
@@ -48,7 +164,14 @@ TxFormat* TxFormats::findByName (std::string const& name)
|
|||||||
return result;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,43 +4,119 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef RIPPLE_TXFORMATS_H
|
#ifndef RIPPLE_TXFORMATS_H_INCLUDED
|
||||||
#define RIPPLE_TXFORMATS_H
|
#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.
|
/** Manages the list of known transaction formats.
|
||||||
*/
|
*/
|
||||||
class TxFormats
|
class TxFormats
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// VFALCO TODO Make this a member of the Application object instead of a singleton?
|
/** A transaction format.
|
||||||
static TxFormats& getInstance ();
|
|
||||||
|
|
||||||
/** Add a format.
|
|
||||||
|
|
||||||
The caller is responsible for freeing the memory.
|
|
||||||
|
|
||||||
@return The passed 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.
|
/** 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.
|
/** 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:
|
private:
|
||||||
TxFormats ();
|
// VFALCO TODO use String instead of std::string
|
||||||
|
typedef std::map <std::string, Item*> NameMap;
|
||||||
private:
|
typedef std::map <TxType, Item*> TypeMap;
|
||||||
typedef std::map <std::string, TxFormat*> NameMap;
|
|
||||||
typedef std::map <TransactionType, TxFormat*> TypeMap;
|
|
||||||
|
|
||||||
|
OwnedArray <Item> m_formats;
|
||||||
NameMap m_names;
|
NameMap m_names;
|
||||||
TypeMap m_types;
|
TypeMap m_types;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim:ts=4
|
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ namespace ripple
|
|||||||
#include "protocol/ripple_SerializedObjectTemplate.cpp"
|
#include "protocol/ripple_SerializedObjectTemplate.cpp"
|
||||||
#include "protocol/ripple_SerializedObject.cpp"
|
#include "protocol/ripple_SerializedObject.cpp"
|
||||||
#include "protocol/ripple_TER.cpp"
|
#include "protocol/ripple_TER.cpp"
|
||||||
#include "protocol/ripple_TxFormat.cpp"
|
|
||||||
#include "protocol/ripple_TxFormats.cpp"
|
#include "protocol/ripple_TxFormats.cpp"
|
||||||
|
|
||||||
// These are for STAmount
|
// These are for STAmount
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ namespace ripple
|
|||||||
#include "protocol/ripple_SerializedObject.h"
|
#include "protocol/ripple_SerializedObject.h"
|
||||||
#include "protocol/ripple_LedgerFormat.h" // needs SOTemplate from SerializedObject
|
#include "protocol/ripple_LedgerFormat.h" // needs SOTemplate from SerializedObject
|
||||||
#include "protocol/ripple_TxFlags.h"
|
#include "protocol/ripple_TxFlags.h"
|
||||||
#include "protocol/ripple_TxFormat.h"
|
|
||||||
#include "protocol/ripple_TxFormats.h"
|
#include "protocol/ripple_TxFormats.h"
|
||||||
|
|
||||||
#include "utility/ripple_UptimeTimerAdapter.h"
|
#include "utility/ripple_UptimeTimerAdapter.h"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ Transaction::pointer Transaction::sharedTransaction (Blob const& vucTransaction,
|
|||||||
//
|
//
|
||||||
|
|
||||||
Transaction::Transaction (
|
Transaction::Transaction (
|
||||||
TransactionType ttKind,
|
TxType ttKind,
|
||||||
const RippleAddress& naPublicKey,
|
const RippleAddress& naPublicKey,
|
||||||
const RippleAddress& naSourceAccount,
|
const RippleAddress& naSourceAccount,
|
||||||
uint32 uSeq,
|
uint32 uSeq,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
static Transaction::pointer transactionFromSQL (Database * db, bool bValidate);
|
static Transaction::pointer transactionFromSQL (Database * db, bool bValidate);
|
||||||
|
|
||||||
Transaction (
|
Transaction (
|
||||||
TransactionType ttKind,
|
TxType ttKind,
|
||||||
const RippleAddress & naPublicKey, // To prove transaction is consistent and authorized.
|
const RippleAddress & naPublicKey, // To prove transaction is consistent and authorized.
|
||||||
const RippleAddress & naSourceAccount, // To identify the paying account.
|
const RippleAddress & naSourceAccount, // To identify the paying account.
|
||||||
uint32 uSeq, // To order transactions.
|
uint32 uSeq, // To order transactions.
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
// VFALCO TODO make these singletons that initialize statically
|
// VFALCO TODO make these singletons that initialize statically
|
||||||
extern void TFInit ();
|
|
||||||
extern void LEFInit ();
|
extern void LEFInit ();
|
||||||
|
|
||||||
void setupServer ()
|
void setupServer ()
|
||||||
@@ -210,7 +209,6 @@ int rippleMain (int argc, char** argv)
|
|||||||
Log::setMinSeverity (lsINFO, true);
|
Log::setMinSeverity (lsINFO, true);
|
||||||
|
|
||||||
// VFALCO TODO make these singletons that initialize statically
|
// VFALCO TODO make these singletons that initialize statically
|
||||||
TFInit ();
|
|
||||||
LEFInit ();
|
LEFInit ();
|
||||||
|
|
||||||
if (vm.count ("unittest"))
|
if (vm.count ("unittest"))
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
{
|
{
|
||||||
return mTxn->getTransactionID ();
|
return mTxn->getTransactionID ();
|
||||||
}
|
}
|
||||||
TransactionType getTxnType () const
|
TxType getTxnType () const
|
||||||
{
|
{
|
||||||
return mTxn->getTxnType ();
|
return mTxn->getTxnType ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
SETUP_LOG (SerializedTransaction)
|
SETUP_LOG (SerializedTransaction)
|
||||||
|
|
||||||
SerializedTransaction::SerializedTransaction (TransactionType type)
|
SerializedTransaction::SerializedTransaction (TxType type)
|
||||||
: STObject (sfTransaction)
|
: STObject (sfTransaction)
|
||||||
, mType (type)
|
, mType (type)
|
||||||
, mSigGood (false)
|
, mSigGood (false)
|
||||||
@@ -14,7 +14,7 @@ SerializedTransaction::SerializedTransaction (TransactionType type)
|
|||||||
{
|
{
|
||||||
mFormat = TxFormats::getInstance().findByType (type);
|
mFormat = TxFormats::getInstance().findByType (type);
|
||||||
|
|
||||||
if (mFormat == NULL)
|
if (mFormat == nullptr)
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, SerializedTransaction) << "Transaction type: " << type;
|
WriteLog (lsWARNING, SerializedTransaction) << "Transaction type: " << type;
|
||||||
throw std::runtime_error ("invalid transaction type");
|
throw std::runtime_error ("invalid transaction type");
|
||||||
@@ -29,7 +29,7 @@ SerializedTransaction::SerializedTransaction (STObject const& object)
|
|||||||
, mSigGood (false)
|
, mSigGood (false)
|
||||||
, mSigBad (false)
|
, mSigBad (false)
|
||||||
{
|
{
|
||||||
mType = static_cast <TransactionType> (getFieldU16 (sfTransactionType));
|
mType = static_cast <TxType> (getFieldU16 (sfTransactionType));
|
||||||
|
|
||||||
mFormat = TxFormats::getInstance().findByType (mType);
|
mFormat = TxFormats::getInstance().findByType (mType);
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ SerializedTransaction::SerializedTransaction (SerializerIterator& sit) : STObjec
|
|||||||
}
|
}
|
||||||
|
|
||||||
set (sit);
|
set (sit);
|
||||||
mType = static_cast<TransactionType> (getFieldU16 (sfTransactionType));
|
mType = static_cast<TxType> (getFieldU16 (sfTransactionType));
|
||||||
|
|
||||||
mFormat = TxFormats::getInstance().findByType (mType);
|
mFormat = TxFormats::getInstance().findByType (mType);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
SerializedTransaction (SerializerIterator & sit);
|
SerializedTransaction (SerializerIterator & sit);
|
||||||
SerializedTransaction (TransactionType type);
|
SerializedTransaction (TxType type);
|
||||||
SerializedTransaction (const STObject & object);
|
SerializedTransaction (const STObject & object);
|
||||||
|
|
||||||
// STObject functions
|
// STObject functions
|
||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
}
|
}
|
||||||
uint256 getSigningHash () const;
|
uint256 getSigningHash () const;
|
||||||
|
|
||||||
TransactionType getTxnType () const
|
TxType getTxnType () const
|
||||||
{
|
{
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
@@ -127,8 +127,8 @@ public:
|
|||||||
std::string getMetaSQL (Serializer rawTxn, uint32 inLedger, char status, const std::string & escapedMetaData) const;
|
std::string getMetaSQL (Serializer rawTxn, uint32 inLedger, char status, const std::string & escapedMetaData) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TransactionType mType;
|
TxType mType;
|
||||||
const TxFormat* mFormat;
|
TxFormats::Item const* mFormat;
|
||||||
|
|
||||||
SerializedTransaction* duplicate () const
|
SerializedTransaction* duplicate () const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user