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)
{
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)
for (int i = 0; i < mPath.size(); ++i)
{
int iType = speElement.getNodeType();
iBytes += 1; // mType
if (iType & STPathElement::typeAccount)
iBytes += 160/8;
if (iType & STPathElement::typeCurrency)
iBytes += 160/8;
if (iType & STPathElement::typeIssuer)
iBytes += 160/8;
const STPathElement& ele = getElement(i);
if (ele.getAccountID() == uAccountId
&& ele.getCurrency() == uCurrencyID
&& ele.getIssuerID() == uIssuerID)
return true;
}
iBytes += 1; // typeBoundary | typeEnd
return iBytes;
return false;
}
Json::Value STPath::getJson(int) const

View File

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