mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Code improvements:
A way to avoid duplicate field indexes that Arthur came up with. Abstract out code to create individual fields. Field index operations. Flag operations. Optional field operations.
This commit is contained in:
@@ -1,49 +1,51 @@
|
||||
|
||||
#include "TransactionFormats.h"
|
||||
|
||||
#define S_FIELD(x) sf##x, #x
|
||||
|
||||
TransactionFormat InnerTxnFormats[]=
|
||||
{
|
||||
{ "MakePayment", ttMAKE_PAYMENT, {
|
||||
{ "Flags", STI_UINT16, SOE_FLAGS, 0 },
|
||||
{ "Sequence", STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ "Destination", STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ "Amount", STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ "Currency", STI_HASH160, SOE_IFFLAG, 1 },
|
||||
{ "SourceTag", STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ "TargetLedger", STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ "InvoiceID", STI_HASH256, SOE_IFFLAG, 8 },
|
||||
{ "Extensions", STI_TL, SOE_IFFLAG, 32768 },
|
||||
{ NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Amount), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Currency), STI_HASH160, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(TargetLedger), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(InvoiceID), STI_HASH256, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 32768 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Invoice", ttINVOICE, {
|
||||
{ "Flags", STI_UINT16, SOE_FLAGS, 0 },
|
||||
{ "Sequence", STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ "Target", STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ "Amount", STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ "Currency", STI_HASH160, SOE_IFFLAG, 1 },
|
||||
{ "SourceTag", STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ "Destination", STI_ACCOUNT, SOE_IFFLAG, 4 },
|
||||
{ "TargetLedger", STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ "Identifier", STI_VL, SOE_IFFLAG, 16 },
|
||||
{ "Extensions", STI_TL, SOE_IFFLAG, 32768 },
|
||||
{ NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Target), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Amount), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Currency), STI_HASH160, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(TargetLedger), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Identifier), STI_VL, SOE_IFFLAG, 16 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 32768 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Offer", ttEXCHANGE_OFFER, {
|
||||
{ "Flags", STI_UINT16, SOE_FLAGS, 0 },
|
||||
{ "Sequence", STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ "AmountIn", STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ "CurrencyIn", STI_HASH160, SOE_IFFLAG, 2 },
|
||||
{ "AmountOut", STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ "CurrencyOut", STI_HASH160, SOE_IFFLAG, 4 },
|
||||
{ "SourceTag", STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ "Destination", STI_ACCOUNT, SOE_IFFLAG, 16 },
|
||||
{ "TargetLedger", STI_UINT32, SOE_IFFLAG, 32 },
|
||||
{ "ExpireLedger", STI_UINT32, SOE_IFFLAG, 64 },
|
||||
{ "Identifier", STI_VL, SOE_IFFLAG, 128 },
|
||||
{ "Extensions", STI_TL, SOE_IFFLAG, 32768 },
|
||||
{ NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AmountIn), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(CurrencyIn), STI_HASH160, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(AmountOut), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(CurrencyOut), STI_HASH160, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_IFFLAG, 16 },
|
||||
{ S_FIELD(TargetLedger), STI_UINT32, SOE_IFFLAG, 32 },
|
||||
{ S_FIELD(ExpireLedger), STI_UINT32, SOE_IFFLAG, 64 },
|
||||
{ S_FIELD(Identifier), STI_VL, SOE_IFFLAG, 128 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 32768 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ NULL, ttINVALID }
|
||||
{ NULL, ttINVALID }
|
||||
};
|
||||
|
||||
TransactionFormat* getFormat(TransactionType t)
|
||||
|
||||
Reference in New Issue
Block a user