mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 18:45:55 +00:00
refactor: reunify transaction common fields: (#4715)
Make transactions and pseudo-transactions share the same commonFields again. This regularizes the code in a nice way. While this technically allows pseudo-transactions to have a TicketSequence field, pseudo-transactions are only ever constructed by code paths that don't add such a field, so this is not a transaction processing change. It may be possible to add a separate check to ensure TicketSequence (and other fields that don't make sense on pseudo-transactions) are never added to pseudo-transactions, but that should not be necessary. (TicketSequence is not the only common field that can not and does not appear in pseudo-transactions.) Note: TicketSequence is already documented as a common field. Related: #4637 Fix #4714
This commit is contained in:
@@ -27,45 +27,29 @@ namespace ripple {
|
|||||||
|
|
||||||
TxFormats::TxFormats()
|
TxFormats::TxFormats()
|
||||||
{
|
{
|
||||||
#pragma push_macro("PSEUDO_TXN_COMMON_FIELDS")
|
// Fields shared by all txFormats:
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#define PSEUDO_TXN_COMMON_FIELDS \
|
|
||||||
{sfTransactionType, soeREQUIRED}, \
|
|
||||||
{sfFlags, soeOPTIONAL}, \
|
|
||||||
{sfSourceTag, soeOPTIONAL}, \
|
|
||||||
{sfAccount, soeREQUIRED}, \
|
|
||||||
{sfSequence, soeREQUIRED}, \
|
|
||||||
{sfPreviousTxnID, soeOPTIONAL}, /* emulate027 */ \
|
|
||||||
{sfLastLedgerSequence, soeOPTIONAL}, \
|
|
||||||
{sfAccountTxnID, soeOPTIONAL}, \
|
|
||||||
{sfFee, soeREQUIRED}, \
|
|
||||||
{sfOperationLimit, soeOPTIONAL}, \
|
|
||||||
{sfMemos, soeOPTIONAL}, \
|
|
||||||
{sfSigningPubKey, soeREQUIRED}, \
|
|
||||||
{sfTxnSignature, soeOPTIONAL}, \
|
|
||||||
{sfSigners, soeOPTIONAL}, /* submit_multisigned */ \
|
|
||||||
{sfEmitDetails, soeOPTIONAL}, \
|
|
||||||
{sfFirstLedgerSequence, soeOPTIONAL}, \
|
|
||||||
{sfNetworkID, soeOPTIONAL}, \
|
|
||||||
{sfHookParameters, soeOPTIONAL}
|
|
||||||
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
// Fields shared by all pseudo-transaction txFormats:
|
|
||||||
static const std::initializer_list<SOElement> pseudoCommonFields{
|
|
||||||
PSEUDO_TXN_COMMON_FIELDS,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Fields shared by all normal transaction txFormats:
|
|
||||||
static const std::initializer_list<SOElement> commonFields{
|
static const std::initializer_list<SOElement> commonFields{
|
||||||
PSEUDO_TXN_COMMON_FIELDS,
|
{sfTransactionType, soeREQUIRED},
|
||||||
|
{sfFlags, soeOPTIONAL},
|
||||||
|
{sfSourceTag, soeOPTIONAL},
|
||||||
|
{sfAccount, soeREQUIRED},
|
||||||
|
{sfSequence, soeREQUIRED},
|
||||||
|
{sfPreviousTxnID, soeOPTIONAL}, // emulate027
|
||||||
|
{sfLastLedgerSequence, soeOPTIONAL},
|
||||||
|
{sfAccountTxnID, soeOPTIONAL},
|
||||||
|
{sfFee, soeREQUIRED},
|
||||||
|
{sfOperationLimit, soeOPTIONAL},
|
||||||
|
{sfMemos, soeOPTIONAL},
|
||||||
|
{sfSigningPubKey, soeREQUIRED},
|
||||||
{sfTicketSequence, soeOPTIONAL},
|
{sfTicketSequence, soeOPTIONAL},
|
||||||
|
{sfTxnSignature, soeOPTIONAL},
|
||||||
|
{sfSigners, soeOPTIONAL}, // submit_multisigned
|
||||||
|
{sfEmitDetails, soeOPTIONAL},
|
||||||
|
{sfFirstLedgerSequence, soeOPTIONAL},
|
||||||
|
{sfNetworkID, soeOPTIONAL},
|
||||||
|
{sfHookParameters, soeOPTIONAL},
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pop_macro("PSEUDO_TXN_COMMON_FIELDS")
|
|
||||||
|
|
||||||
add(jss::AccountSet,
|
add(jss::AccountSet,
|
||||||
ttACCOUNT_SET,
|
ttACCOUNT_SET,
|
||||||
{
|
{
|
||||||
@@ -244,7 +228,7 @@ TxFormats::TxFormats()
|
|||||||
{sfLedgerSequence, soeREQUIRED},
|
{sfLedgerSequence, soeREQUIRED},
|
||||||
{sfAmendment, soeREQUIRED},
|
{sfAmendment, soeREQUIRED},
|
||||||
},
|
},
|
||||||
pseudoCommonFields);
|
commonFields);
|
||||||
|
|
||||||
add(jss::EmitFailure,
|
add(jss::EmitFailure,
|
||||||
ttEMIT_FAILURE,
|
ttEMIT_FAILURE,
|
||||||
@@ -268,7 +252,7 @@ TxFormats::TxFormats()
|
|||||||
{sfReserveBaseDrops, soeOPTIONAL},
|
{sfReserveBaseDrops, soeOPTIONAL},
|
||||||
{sfReserveIncrementDrops, soeOPTIONAL},
|
{sfReserveIncrementDrops, soeOPTIONAL},
|
||||||
},
|
},
|
||||||
pseudoCommonFields);
|
commonFields);
|
||||||
|
|
||||||
add(jss::UNLModify,
|
add(jss::UNLModify,
|
||||||
ttUNL_MODIFY,
|
ttUNL_MODIFY,
|
||||||
@@ -277,7 +261,7 @@ TxFormats::TxFormats()
|
|||||||
{sfLedgerSequence, soeREQUIRED},
|
{sfLedgerSequence, soeREQUIRED},
|
||||||
{sfUNLModifyValidator, soeREQUIRED},
|
{sfUNLModifyValidator, soeREQUIRED},
|
||||||
},
|
},
|
||||||
pseudoCommonFields);
|
commonFields);
|
||||||
|
|
||||||
add(jss::UNLReport,
|
add(jss::UNLReport,
|
||||||
ttUNL_REPORT,
|
ttUNL_REPORT,
|
||||||
|
|||||||
Reference in New Issue
Block a user