address reviews

This commit is contained in:
tequ
2025-10-22 15:43:35 +09:00
parent 9ef778fd48
commit 152db53a4f
2 changed files with 11 additions and 7 deletions

View File

@@ -658,15 +658,15 @@ SetAccount::doApply()
// HookStateScale
if (tx.isFieldPresent(sfHookStateScale))
{
uint16_t const scale = tx.getFieldU16(sfHookStateScale);
uint16_t const newScale = tx.getFieldU16(sfHookStateScale);
uint16_t const oldScale = sle->isFieldPresent(sfHookStateScale)
? sle->getFieldU16(sfHookStateScale)
: 1;
if (scale == oldScale)
if (newScale == oldScale)
{
// do nothing
}
else if (scale == 1)
else if (newScale == 1)
{
sle->makeFieldAbsent(sfHookStateScale);
}
@@ -676,8 +676,12 @@ SetAccount::doApply()
uint32_t const stateCount = sle->getFieldU32(sfHookStateCount);
uint32_t const oldOwnerCount = sle->getFieldU32(sfOwnerCount);
uint32_t const newOwnerCount =
oldOwnerCount - (oldScale * stateCount) + (scale * stateCount);
uint32_t const newOwnerCount = oldOwnerCount -
(oldScale * stateCount) + (newScale * stateCount);
// sanity check
// if stateCount == 0, then newOwnerCount == oldOwnerCount
assert(newOwnerCount >= oldOwnerCount);
STAmount const balance = STAmount((*sle)[sfBalance]).xrp();
XRPAmount const reserve =
@@ -689,7 +693,7 @@ SetAccount::doApply()
adjustOwnerCount(
view(), sle, newOwnerCount - oldOwnerCount, j_);
sle->setFieldU16(sfHookStateScale, scale);
sle->setFieldU16(sfHookStateScale, newScale);
}
}

View File

@@ -94,7 +94,7 @@ transResults()
MAKE_ERROR(tecINSUF_RESERVE_SELLER, "The seller of an object has insufficient reserves, and thus cannot complete the sale."),
MAKE_ERROR(tecIMMUTABLE, "The remark is marked immutable on the object, and therefore cannot be updated."),
MAKE_ERROR(tecTOO_MANY_REMARKS, "The number of remarks on the object would exceed the limit of 32."),
MAKE_ERROR(tecHAS_HOOK_STATE, "The account has hook state. Delete all existing state first."),
MAKE_ERROR(tecHAS_HOOK_STATE, "Delete all hook state before reducing scale"),
MAKE_ERROR(tefALREADY, "The exact transaction was already in this ledger."),
MAKE_ERROR(tefBAD_ADD_AUTH, "Not authorized to add account."),