mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-27 00:50:45 +00:00
Review feedback
- Use a lambda to defensively guarantee that "tx" can not affect the "signerCount" in "LoanSet::calculateBaseFee" # Please enter the commit message for your changes. Lines starting
This commit is contained in:
@@ -159,9 +159,13 @@ LoanSet::calculateBaseFee(ReadView const& view, STTx const& tx)
|
||||
// for the transaction. Note that unlike the base class, the single signer
|
||||
// is counted if present. It will only be absent in a batch inner
|
||||
// transaction.
|
||||
std::size_t const signerCount = counterSig.isFieldPresent(sfSigners)
|
||||
? counterSig.getFieldArray(sfSigners).size()
|
||||
: (counterSig.isFieldPresent(sfTxnSignature) ? 1 : 0);
|
||||
std::size_t const signerCount = [&counterSig]() {
|
||||
// Compute defensively. Assure that "tx" cannot be accessed and cause
|
||||
// confusion or miscalculations.
|
||||
return counterSig.isFieldPresent(sfSigners)
|
||||
? counterSig.getFieldArray(sfSigners).size()
|
||||
: (counterSig.isFieldPresent(sfTxnSignature) ? 1 : 0);
|
||||
}();
|
||||
|
||||
return normalCost + (signerCount * baseFee);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user