From d12eb086198de53f668e06e0f0f450f17303fe6d Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 24 Nov 2012 10:57:06 -0800 Subject: [PATCH 1/2] Cleanup. --- src/cpp/ripple/SerializeProto.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/cpp/ripple/SerializeProto.h b/src/cpp/ripple/SerializeProto.h index 8b5920f644..92da4ecf2a 100644 --- a/src/cpp/ripple/SerializeProto.h +++ b/src/cpp/ripple/SerializeProto.h @@ -2,23 +2,23 @@ // appropriate #define statements. // types (common) - TYPE("Int16", UINT16, 1) - TYPE("Int32", UINT32, 2) - TYPE("Int64", UINT64, 3) - TYPE("Hash128", HASH128, 4) - TYPE("Hash256", HASH256, 5) - TYPE("Amount", AMOUNT, 6) - TYPE("VariableLength", VL, 7) - TYPE("Account", ACCOUNT, 8) + TYPE(Int16, UINT16, 1) + TYPE(Int32, UINT32, 2) + TYPE(Int64, UINT64, 3) + TYPE(Hash128, HASH128, 4) + TYPE(Hash256, HASH256, 5) + TYPE(Amount, AMOUNT, 6) + TYPE(VariableLength, VL, 7) + TYPE(Account, ACCOUNT, 8) // 9-13 are reserved - TYPE("Object", OBJECT, 14) - TYPE("Array", ARRAY, 15) + TYPE(Object, OBJECT, 14) + TYPE(Array, ARRAY, 15) // types (uncommon) - TYPE("Int8", UINT8, 16) - TYPE("Hash160", HASH160, 17) - TYPE("PathSet", PATHSET, 18) - TYPE("Vector256", VECTOR256, 19) + TYPE(Int8, UINT8, 16) + TYPE(Hash160, HASH160, 17) + TYPE(PathSet, PATHSET, 18) + TYPE(Vector256, VECTOR256, 19) From a9d9353f9bc3b45367ebb73d1e38fd368ccbaef2 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sat, 24 Nov 2012 11:02:27 -0800 Subject: [PATCH 2/2] Remove TaggedList's, they're obsolete. --- src/cpp/ripple/SerializedObject.h | 2 - src/cpp/ripple/Serializer.cpp | 105 ------------------------------ src/cpp/ripple/Serializer.h | 9 --- 3 files changed, 116 deletions(-) diff --git a/src/cpp/ripple/SerializedObject.h b/src/cpp/ripple/SerializedObject.h index d0d3ce6afe..5bf84eb6cb 100644 --- a/src/cpp/ripple/SerializedObject.h +++ b/src/cpp/ripple/SerializedObject.h @@ -116,7 +116,6 @@ public: RippleAddress getFieldAccount(SField::ref field) const; uint160 getFieldAccount160(SField::ref field) const; std::vector getFieldVL(SField::ref field) const; - std::vector getFieldTL(SField::ref field) const; STAmount getFieldAmount(SField::ref field) const; STPathSet getFieldPathSet(SField::ref field) const; STVector256 getFieldV256(SField::ref field) const; @@ -129,7 +128,6 @@ public: void setFieldH160(SField::ref field, const uint160&); void setFieldH256(SField::ref field, const uint256&); void setFieldVL(SField::ref field, const std::vector&); - void setFieldTL(SField::ref field, const std::vector&); void setFieldAccount(SField::ref field, const uint160&); void setFieldAccount(SField::ref field, const RippleAddress& addr) { setFieldAccount(field, addr.getAccountID()); } diff --git a/src/cpp/ripple/Serializer.cpp b/src/cpp/ripple/Serializer.cpp index 016c6e2a6b..4c602eb043 100644 --- a/src/cpp/ripple/Serializer.cpp +++ b/src/cpp/ripple/Serializer.cpp @@ -380,64 +380,6 @@ int Serializer::addVL(const std::string& string) return ret; } -int Serializer::addTaggedList(const std::list& list) -{ - int size = list.size(); - if (size > 255) return -1; - int ret = add8(size); - if (size != 0) - { - BOOST_FOREACH(const TaggedListItem& it, list) - { - add8(it.first); - addVL(it.second); - } - } - return ret; -} - -int Serializer::addTaggedList(const std::vector& list) -{ - int size = list.size(); - if (size > 255) return -1; - int ret = add8(size); - if (size != 0) - { - BOOST_FOREACH(const TaggedListItem& it, list) - { - add8(it.first); - addVL(it.second); - } - } - return ret; -} - -int Serializer::getTaggedListLength(const std::list& list) -{ - int size = list.size(); - if (size > 255) return -1; - int ret = 1; - if (size != 0) - { - BOOST_FOREACH(const TaggedListItem& it, list) - ret += 1 + it.second.size() + Serializer::encodeLengthLength(it.second.size()); - } - return ret; -} - -int Serializer::getTaggedListLength(const std::vector& list) -{ - int size = list.size(); - if (size > 255) return -1; - int ret = 1; - if (size != 0) - { - BOOST_FOREACH(const TaggedListItem& it, list) - ret += 1 + it.second.size() + Serializer::encodeLengthLength(it.second.size()); - } - return ret; -} - bool Serializer::getVL(std::vector& objectVL, int offset, int& length) const { int b1; @@ -503,44 +445,6 @@ bool Serializer::getVLLength(int& length, int offset) const return true; } -bool Serializer::getTaggedList(std::list& list, int offset, int& length) const -{ - list.clear(); - int startOffset = offset; - int numElem; - if (!get8(numElem, offset++)) return false; - for (int i = 0; i data; - if (!get8(tag, offset++)) return false; - if (!getVL(data, offset, len)) return false; - offset += len; - list.push_back(std::make_pair(tag, data)); - } - length = offset - startOffset; - return true; -} - -bool Serializer::getTaggedList(std::vector& list, int offset, int& length) const -{ - list.clear(); - int startOffset = offset; - int numElem; - if (!get8(numElem, offset++)) return false; - for (int i = 0; i data; - if (!get8(tag, offset++)) return false; - if (!getVL(data, offset, len)) return false; - offset += len; - list.push_back(std::make_pair(tag, data)); - } - length = offset - startOffset; - return true; -} - std::vector Serializer::encodeVL(int length) { unsigned char lenBytes[4]; @@ -692,15 +596,6 @@ std::vector SerializerIterator::getVL() return vl; } -std::vector SerializerIterator::getTaggedList() -{ - int length; - std::vector tl; - if (!mSerializer.getTaggedList(tl, mPos, length)) throw std::runtime_error("invalid serializer getTL"); - mPos += length; - return tl; -} - std::vector SerializerIterator::getRaw(int iLength) { int iPos = mPos; diff --git a/src/cpp/ripple/Serializer.h b/src/cpp/ripple/Serializer.h index 4bb929b199..8d9a88efc5 100644 --- a/src/cpp/ripple/Serializer.h +++ b/src/cpp/ripple/Serializer.h @@ -11,8 +11,6 @@ #include "uint256.h" #include "FieldNames.h" -typedef std::pair > TaggedListItem; - class Serializer { public: @@ -46,10 +44,6 @@ public: int addVL(const std::vector &vector); int addVL(const std::string& string); int addVL(const void *ptr, int len); - int addTaggedList(const std::list&); - int addTaggedList(const std::vector&); - static int getTaggedListLength(const std::list&); - static int getTaggedListLength(const std::vector&); // disassemble functions bool get8(int&, int offset) const; @@ -66,8 +60,6 @@ public: bool getVL(std::vector& objectVL, int offset, int& length) const; bool getVLLength(int& length, int offset) const; - bool getTaggedList(std::list&, int offset, int& length) const; - bool getTaggedList(std::vector&, int offset, int& length) const; bool getFieldID(int& type, int& name, int offset) const; int addFieldID(int type, int name); @@ -171,7 +163,6 @@ public: std::vector getRaw(int iLength); std::vector getVL(); - std::vector getTaggedList(); }; #endif