From 9fa335af6350a1a118875e3780aa8488ba80a54e Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 12 Apr 2012 16:02:20 -0700 Subject: [PATCH] Update to 32-bit flags. A few serialized transaction fixes. --- src/LedgerFormats.cpp | 12 ++++++------ src/SerializedObject.cpp | 18 +++++++++--------- src/SerializedObject.h | 6 +++--- src/SerializedTransaction.h | 7 +++---- src/TransactionFormats.cpp | 12 ++++++------ 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/LedgerFormats.cpp b/src/LedgerFormats.cpp index 1f76a9ffa..429d05f53 100644 --- a/src/LedgerFormats.cpp +++ b/src/LedgerFormats.cpp @@ -6,7 +6,7 @@ LedgerEntryFormat LedgerFormats[]= { { "AccountRoot", ltACCOUNT_ROOT, { - { S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 }, + { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 }, { S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 }, @@ -15,11 +15,11 @@ LedgerEntryFormat LedgerFormats[]= { S_FIELD(EmailHash), STI_HASH128, SOE_IFFLAG, 1 }, { S_FIELD(WalletLocator),STI_HASH256, SOE_IFFLAG, 2 }, { S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 4 }, - { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 32768 }, + { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } }, { "RippleState", ltRIPPLE_STATE, { - { S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 }, + { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Borrower), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Lender), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Currency), STI_HASH160, SOE_IFFLAG, 1 }, @@ -30,16 +30,16 @@ LedgerEntryFormat LedgerFormats[]= { S_FIELD(NextRate), STI_UINT32, SOE_IFFLAG, 8 }, { S_FIELD(NextRateLgr), STI_UINT32, SOE_IFFLAG, 8 }, { S_FIELD(NextRateExp), STI_UINT32, SOE_IFFLAG, 16 }, - { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 32768 }, + { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } }, { "Nickname", ltNICKNAME, { - { S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 }, + { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Nickname), STI_HASH256, SOE_REQUIRED, 0 }, { S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(MinimumOffer), STI_AMOUNT, SOE_IFFLAG, 1 }, { S_FIELD(OfferCurrency),STI_HASH160, SOE_IFFLAG, 2 }, - { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 32768 }, + { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } }, { NULL, ltINVALID } diff --git a/src/SerializedObject.cpp b/src/SerializedObject.cpp index 576d90103..1a9f7a56c 100644 --- a/src/SerializedObject.cpp +++ b/src/SerializedObject.cpp @@ -112,9 +112,9 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) : } else if(elem->e_type==SOE_FLAGS) { - assert(elem->e_id==STI_UINT16); - flags=sit.get16(); - mFlagIdx=giveObject(new STUInt16(elem->e_name, flags)); + assert(elem->e_id==STI_UINT32); + flags=sit.get32(); + mFlagIdx=giveObject(new STUInt32(elem->e_name, flags)); done=true; } if(!done) @@ -232,28 +232,28 @@ bool STObject::isFieldPresent(SOE_Field field) const return peekAtIndex(field).getSType()==STI_OBJECT; } -bool STObject::setFlag(int f) +bool STObject::setFlag(uint32 f) { if(mFlagIdx<0) return false; - STUInt16* t=dynamic_cast(getPIndex(mFlagIdx)); + STUInt32* t=dynamic_cast(getPIndex(mFlagIdx)); assert(t); t->setValue(t->getValue() | f); return true; } -bool STObject::clearFlag(int f) +bool STObject::clearFlag(uint32 f) { if(mFlagIdx<0) return false; - STUInt16* t=dynamic_cast(getPIndex(mFlagIdx)); + STUInt32* t=dynamic_cast(getPIndex(mFlagIdx)); assert(t); t->setValue(t->getValue() & ~f); return true; } -int STObject::getFlag(void) const +uint32 STObject::getFlags(void) const { if(mFlagIdx<0) return 0; - const STUInt16* t=dynamic_cast(peekAtPIndex(mFlagIdx)); + const STUInt32* t=dynamic_cast(peekAtPIndex(mFlagIdx)); assert(t); return t->getValue(); } diff --git a/src/SerializedObject.h b/src/SerializedObject.h index 89273571f..bb774388e 100644 --- a/src/SerializedObject.h +++ b/src/SerializedObject.h @@ -72,9 +72,9 @@ public: int getCount() const { return mData.size(); } - bool setFlag(int); - bool clearFlag(int); - int getFlag() const; + bool setFlag(uint32); + bool clearFlag(uint32); + uint32 getFlags() const; const SerializedType& peekAtIndex(int offset) const { return mData[offset]; } SerializedType& getIndex(int offset) { return mData[offset]; } diff --git a/src/SerializedTransaction.h b/src/SerializedTransaction.h index 5ec8ca700..142e93f20 100644 --- a/src/SerializedTransaction.h +++ b/src/SerializedTransaction.h @@ -52,10 +52,9 @@ public: std::string getTransactionType() const { return mFormat->t_name; } // inner transaction functions - uint16 getFlags() const; - void setFlag(int v); - void clearFlag(int v); - bool isFlag(int v); + uint32 getFlags() const { return mInnerTxn.getFlags(); } + void setFlag(uint32 v) { mInnerTxn.setFlag(v); } + void clearFlag(uint32 v) { mInnerTxn.clearFlag(v); } uint32 getSequence() const; void setSequence(uint32); diff --git a/src/TransactionFormats.cpp b/src/TransactionFormats.cpp index c59a78e63..b285c2dcb 100644 --- a/src/TransactionFormats.cpp +++ b/src/TransactionFormats.cpp @@ -6,18 +6,18 @@ TransactionFormat InnerTxnFormats[]= { { "MakePayment", ttMAKE_PAYMENT, { - { S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 }, + { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Amount), STI_AMOUNT, 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 }, + { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } }, { "Invoice", ttINVOICE, { - { S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 }, + { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Target), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Currency), STI_HASH160, SOE_IFFLAG, 1 }, @@ -25,11 +25,11 @@ TransactionFormat InnerTxnFormats[]= { 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 }, + { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } }, { "Offer", ttEXCHANGE_OFFER, { - { S_FIELD(Flags), STI_UINT16, SOE_FLAGS, 0 }, + { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(AmountIn), STI_AMOUNT, SOE_REQUIRED, 0 }, { S_FIELD(CurrencyIn), STI_HASH160, SOE_IFFLAG, 2 }, { S_FIELD(AmountOut), STI_AMOUNT, SOE_REQUIRED, 0 }, @@ -39,7 +39,7 @@ TransactionFormat InnerTxnFormats[]= { 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 }, + { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } }, { NULL, ttINVALID }