Fixes for paths.

This commit is contained in:
Arthur Britto
2012-08-20 12:37:36 -07:00
parent 1c5481bad7
commit 2522c4625f
4 changed files with 39 additions and 14 deletions

View File

@@ -361,16 +361,41 @@ bool STPathSet::isEquivalent(const SerializedType& t) const
return v && (value == v->value);
}
int STPath::getSerializeSize() const
{
int iBytes = 0;
BOOST_FOREACH(const STPathElement& speElement, mPath)
{
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;
}
iBytes += 1; // typeBoundary | typeEnd
return iBytes;
}
int STPathSet::getLength() const
{
// XXX This code is broken?
assert(false);
int ret = 0;
int iBytes = 0;
for (std::vector<STPath>::const_iterator it = value.begin(), end = value.end(); it != end; ++it)
ret += it->getSerializeSize();
BOOST_FOREACH(const STPath& spPath, value)
{
iBytes += spPath.getSerializeSize();
}
return (ret != 0) ? ret : (ret + 1);
return iBytes ? iBytes : 1;
}
Json::Value STPath::getJson(int) const