diff --git a/src/FieldNames.cpp b/src/FieldNames.cpp index 98ba23616..d631fb7f0 100644 --- a/src/FieldNames.cpp +++ b/src/FieldNames.cpp @@ -7,6 +7,10 @@ #include +// These must stay at the top of this file +std::map SField::codeToField; +boost::mutex SField::mapMutex; + SField sfInvalid(-1), sfGeneric(0); SField sfLedgerEntry(FIELD_CODE(STI_LEDGERENTRY, 1), STI_LEDGERENTRY, 1, "LedgerEntry"); SField sfTransaction(FIELD_CODE(STI_TRANSACTION, 1), STI_TRANSACTION, 1, "Transaction"); @@ -18,8 +22,6 @@ SField sfValidation(FIELD_CODE(STI_VALIDATION, 1), STI_VALIDATION, 1, "Validatio #undef FIELD #undef TYPE -std::map SField::codeToField; -boost::mutex SField::mapMutex; SField::ref SField::getField(int code) { diff --git a/src/LedgerFormats.cpp b/src/LedgerFormats.cpp index 37cc7906e..59aa5fd66 100644 --- a/src/LedgerFormats.cpp +++ b/src/LedgerFormats.cpp @@ -1,10 +1,14 @@ #include "LedgerFormats.h" +#define LEF_BASE \ + { sfLedgerEntryType, SOE_REQUIRED }, \ + { sfFlags, SOE_REQUIRED }, \ + { sfLedgerIndex, SOE_OPTIONAL }, + LedgerEntryFormat LedgerFormats[]= { - { "AccountRoot", ltACCOUNT_ROOT, { - { sfFlags, SOE_REQUIRED }, + { "AccountRoot", ltACCOUNT_ROOT, { LEF_BASE { sfAccount, SOE_REQUIRED }, { sfSequence, SOE_REQUIRED }, { sfBalance, SOE_REQUIRED }, @@ -20,7 +24,8 @@ LedgerEntryFormat LedgerFormats[]= { sfPublishSize, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "Contract", ltCONTRACT, { + { "Contract", ltCONTRACT, { LEF_BASE + { sfLedgerEntryType,SOE_REQUIRED }, { sfFlags, SOE_REQUIRED }, { sfAccount, SOE_REQUIRED }, { sfBalance, SOE_REQUIRED }, @@ -36,25 +41,29 @@ LedgerEntryFormat LedgerFormats[]= { sfExpireCode, SOE_REQUIRED }, { sfInvalid, SOE_END } } }, - { "DirectoryNode", ltDIR_NODE, { + { "DirectoryNode", ltDIR_NODE, { LEF_BASE + { sfLedgerEntryType,SOE_REQUIRED }, { sfFlags, SOE_REQUIRED }, { sfIndexes, SOE_REQUIRED }, { sfIndexNext, SOE_OPTIONAL }, { sfIndexPrevious, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "GeneratorMap", ltGENERATOR_MAP, { + { "GeneratorMap", ltGENERATOR_MAP, { LEF_BASE + { sfLedgerEntryType,SOE_REQUIRED }, { sfFlags, SOE_REQUIRED }, { sfGenerator, SOE_REQUIRED }, { sfInvalid, SOE_END } } }, - { "Nickname", ltNICKNAME, { + { "Nickname", ltNICKNAME, { LEF_BASE + { sfLedgerEntryType,SOE_REQUIRED }, { sfFlags, SOE_REQUIRED }, { sfAccount, SOE_REQUIRED }, { sfMinimumOffer, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "Offer", ltOFFER, { + { "Offer", ltOFFER, { LEF_BASE + { sfLedgerEntryType,SOE_REQUIRED }, { sfFlags, SOE_REQUIRED }, { sfAccount, SOE_REQUIRED }, { sfSequence, SOE_REQUIRED }, @@ -68,7 +77,8 @@ LedgerEntryFormat LedgerFormats[]= { sfExpiration, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "RippleState", ltRIPPLE_STATE, { + { "RippleState", ltRIPPLE_STATE, { LEF_BASE + { sfLedgerEntryType,SOE_REQUIRED }, { sfFlags, SOE_REQUIRED }, { sfBalance, SOE_REQUIRED }, { sfLowID, SOE_REQUIRED }, diff --git a/src/TransactionFormats.cpp b/src/TransactionFormats.cpp index a23d82320..2216180dd 100644 --- a/src/TransactionFormats.cpp +++ b/src/TransactionFormats.cpp @@ -1,9 +1,14 @@ #include "TransactionFormats.h" +#define TF_BASE \ + { sfTransactionType, SOE_REQUIRED }, \ + { sfFlags, SOE_REQUIRED }, \ + { sfSignature, SOE_OPTIONAL }, + TransactionFormat InnerTxnFormats[]= { - { "AccountSet", ttACCOUNT_SET, { + { "AccountSet", ttACCOUNT_SET, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfSourceTag, SOE_OPTIONAL }, { sfEmailHash, SOE_OPTIONAL }, @@ -15,7 +20,7 @@ TransactionFormat InnerTxnFormats[]= { sfPublishSize, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "Claim", ttCLAIM, { + { "Claim", ttCLAIM, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfGenerator, SOE_REQUIRED }, { sfPublicKey, SOE_REQUIRED }, @@ -23,7 +28,7 @@ TransactionFormat InnerTxnFormats[]= { sfSourceTag, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "CreditSet", ttCREDIT_SET, { + { "CreditSet", ttCREDIT_SET, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfDestination, SOE_REQUIRED }, { sfSourceTag, SOE_OPTIONAL }, @@ -33,7 +38,7 @@ TransactionFormat InnerTxnFormats[]= { sfInvalid, SOE_END } } }, /* - { "Invoice", ttINVOICE, { + { "Invoice", ttINVOICE, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfTarget, SOE_REQUIRED }, { sfAmount, SOE_REQUIRED }, @@ -43,7 +48,7 @@ TransactionFormat InnerTxnFormats[]= { sfInvalid, SOE_END } } }, */ - { "NicknameSet", ttNICKNAME_SET, { + { "NicknameSet", ttNICKNAME_SET, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfNickname, SOE_REQUIRED }, { sfMinimumOffer, SOE_OPTIONAL }, @@ -51,7 +56,7 @@ TransactionFormat InnerTxnFormats[]= { sfSourceTag, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "OfferCreate", ttOFFER_CREATE, { + { "OfferCreate", ttOFFER_CREATE, { TF_BASE { sfFlags, SOE_REQUIRED}, { sfTakerPays, SOE_REQUIRED }, { sfTakerGets, SOE_REQUIRED }, @@ -59,19 +64,19 @@ TransactionFormat InnerTxnFormats[]= { sfExpiration, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "OfferCancel", ttOFFER_CANCEL, { + { "OfferCancel", ttOFFER_CANCEL, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfOfferSequence, SOE_REQUIRED }, { sfSourceTag, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "PasswordFund", ttPASSWORD_FUND, { + { "PasswordFund", ttPASSWORD_FUND, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfDestination, SOE_REQUIRED }, { sfSourceTag, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "PasswordSet", ttPASSWORD_SET, { + { "PasswordSet", ttPASSWORD_SET, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfAuthorizedKey, SOE_REQUIRED }, { sfGenerator, SOE_REQUIRED }, @@ -80,7 +85,7 @@ TransactionFormat InnerTxnFormats[]= { sfSourceTag, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "Payment", ttPAYMENT, { + { "Payment", ttPAYMENT, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfDestination, SOE_REQUIRED }, { sfAmount, SOE_REQUIRED }, @@ -90,7 +95,7 @@ TransactionFormat InnerTxnFormats[]= { sfInvoiceID, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "WalletAdd", ttWALLET_ADD, { + { "WalletAdd", ttWALLET_ADD, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfAmount, SOE_REQUIRED }, { sfAuthorizedKey, SOE_REQUIRED }, @@ -99,7 +104,7 @@ TransactionFormat InnerTxnFormats[]= { sfSourceTag, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "Contract", ttCONTRACT, { + { "Contract", ttCONTRACT, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfExpiration, SOE_REQUIRED }, { sfBondAmount, SOE_REQUIRED }, @@ -111,7 +116,7 @@ TransactionFormat InnerTxnFormats[]= { sfExpireCode, SOE_OPTIONAL }, { sfInvalid, SOE_END } } }, - { "RemoveContract", ttCONTRACT_REMOVE, { + { "RemoveContract", ttCONTRACT_REMOVE, { TF_BASE { sfFlags, SOE_REQUIRED }, { sfTarget, SOE_REQUIRED }, { sfInvalid, SOE_END } }