mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add support for H128 to Serialized classes.
This commit is contained in:
@@ -401,6 +401,17 @@ uint64 STObject::getValueFieldU64(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
uint128 STObject::getValueFieldH128(SOE_Field field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
SerializedTypeID id = rf->getSType();
|
||||
if (id == STI_NOTPRESENT) return uint128(); // optional field not present
|
||||
const STHash128 *cf = dynamic_cast<const STHash128 *>(rf);
|
||||
if (!cf) throw std::runtime_error("Wrong field type");
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
uint160 STObject::getValueFieldH160(SOE_Field field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
@@ -525,6 +536,16 @@ void STObject::setValueFieldU64(SOE_Field field, uint64 v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldH128(SOE_Field field, const uint128& v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
if (rf->getSType() == STI_NOTPRESENT) rf = makeFieldPresent(field);
|
||||
STHash128* cf = dynamic_cast<STHash128*>(rf);
|
||||
if (!cf) throw std::runtime_error("Wrong field type");
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldH160(SOE_Field field, const uint160& v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
|
||||
Reference in New Issue
Block a user