Cleanups.

This commit is contained in:
JoelKatz
2013-03-05 09:54:57 -08:00
parent f8ee8bc826
commit 8d7a2cd8d7
2 changed files with 15 additions and 38 deletions

View File

@@ -421,41 +421,15 @@ bool STPathSet::isEquivalent(const SerializedType& t) const
bool STPath::hasSeen(const uint160 &uAccountId, const uint160& uCurrencyID, const uint160& uIssuerID) bool STPath::hasSeen(const uint160 &uAccountId, const uint160& uCurrencyID, const uint160& uIssuerID)
{ {
for (int i = 0; i < mPath.size(); ++i) { for (int i = 0; i < mPath.size(); ++i)
STPathElement ele = getElement(i);
if (ele.getAccountID() == uAccountId
&& ele.getCurrency() == uCurrencyID
&& ele.getIssuerID() == uIssuerID)
return true;
}
return false;
}
int STPath::getSerializeSize() const
{
int iBytes = 0;
BOOST_FOREACH(const STPathElement& speElement, mPath)
{ {
int iType = speElement.getNodeType(); const STPathElement& ele = getElement(i);
if (ele.getAccountID() == uAccountId
iBytes += 1; // mType && ele.getCurrency() == uCurrencyID
&& ele.getIssuerID() == uIssuerID)
if (iType & STPathElement::typeAccount) return true;
iBytes += 160/8;
if (iType & STPathElement::typeCurrency)
iBytes += 160/8;
if (iType & STPathElement::typeIssuer)
iBytes += 160/8;
} }
return false;
iBytes += 1; // typeBoundary | typeEnd
return iBytes;
} }
Json::Value STPath::getJson(int) const Json::Value STPath::getJson(int) const

View File

@@ -34,10 +34,14 @@ enum PathFlags
PF_ISSUE = 0x80, PF_ISSUE = 0x80,
}; };
#define CURRENCY_XRP uint160(0) static const uint160 u160_zero(0), u160_one(1);
#define CURRENCY_ONE uint160(1) // Used as a place holder static inline const uint160& get_u160_zero() { return u160_zero; }
#define ACCOUNT_XRP uint160(0) static inline const uint160& get_u160_one() { return u160_one; }
#define ACCOUNT_ONE uint160(1) // Used as a place holder
#define CURRENCY_XRP get_u160_zero()
#define CURRENCY_ONE get_u160_one() // Used as a place holder
#define ACCOUNT_XRP get_u160_zero()
#define ACCOUNT_ONE get_u160_one() // Used as a place holder
DEFINE_INSTANCE(SerializedValue); DEFINE_INSTANCE(SerializedValue);
@@ -685,7 +689,6 @@ public:
void addElement(const STPathElement &e) { mPath.push_back(e); } void addElement(const STPathElement &e) { mPath.push_back(e); }
void clear() { mPath.clear(); } void clear() { mPath.clear(); }
bool hasSeen(const uint160 &uAccountId, const uint160& uCurrencyID, const uint160& uIssuerID); bool hasSeen(const uint160 &uAccountId, const uint160& uCurrencyID, const uint160& uIssuerID);
int getSerializeSize() const;
// std::string getText() const; // std::string getText() const;
Json::Value getJson(int) const; Json::Value getJson(int) const;