Cleanups.

This commit is contained in:
JoelKatz
2012-10-25 19:13:36 -07:00
parent 1952dd41c4
commit 601181c691
4 changed files with 72 additions and 55 deletions

View File

@@ -565,7 +565,8 @@ uint160 STObject::getFieldH160(SField::ref field) const
uint256 STObject::getFieldH256(SField::ref field) const
{
const SerializedType* rf = peekAtPField(field);
if (!rf) throw std::runtime_error("Field not found");
if (!rf)
throw std::runtime_error("Field not found");
SerializedTypeID id = rf->getSType();
if (id == STI_NOTPRESENT) return uint256(); // optional field not present
const STHash256 *cf = dynamic_cast<const STHash256 *>(rf);
@@ -577,17 +578,12 @@ RippleAddress STObject::getFieldAccount(SField::ref field) const
{
const SerializedType* rf = peekAtPField(field);
if (!rf)
{
#ifdef DEBUG
std::cerr << "Account field not found" << std::endl;
std::cerr << getFullText() << std::endl;
#endif
throw std::runtime_error("Field not found");
}
SerializedTypeID id = rf->getSType();
if (id == STI_NOTPRESENT) return RippleAddress(); // optional field not present
const STAccount* cf = dynamic_cast<const STAccount *>(rf);
if (!cf) throw std::runtime_error("Wrong field type");
if (!cf)
throw std::runtime_error("Wrong field type");
return cf->getValueNCA();
}
@@ -596,18 +592,13 @@ uint160 STObject::getFieldAccount160(SField::ref field) const
uint160 a;
const SerializedType* rf = peekAtPField(field);
if (!rf)
{
#ifdef DEBUG
std::cerr << "Account field not found" << std::endl;
std::cerr << getFullText() << std::endl;
#endif
throw std::runtime_error("Field not found");
}
SerializedTypeID id = rf->getSType();
if (id != STI_NOTPRESENT)
{
const STAccount* cf = dynamic_cast<const STAccount *>(rf);
if (!cf) throw std::runtime_error("Wrong field type");
if (!cf)
throw std::runtime_error("Wrong field type");
cf->getValueH160(a);
}
return a;