Make GetEntriesForConflicts return std::optional

Avoids reusing err_string.
This commit is contained in:
glozow
2021-09-02 15:27:37 +01:00
parent b3a2b8c29f
commit f8ad2a57c6
3 changed files with 12 additions and 15 deletions

View File

@@ -789,7 +789,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
fReplacementTransaction = setConflicts.size();
if (fReplacementTransaction)
{
std::string err_string;
CFeeRate newFeeRate(nModifiedFees, nSize);
for (const auto& mi : setIterConflicting) {
// Don't allow the replacement to reduce the feerate of the
@@ -818,8 +817,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
}
// Calculate all conflicting entries and enforce Rule #5.
if (!GetEntriesForConflicts(tx, m_pool, setIterConflicting, allConflicting, err_string)) {
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "too many potential replacements", err_string);
if (const auto err_string{GetEntriesForConflicts(tx, m_pool, setIterConflicting, allConflicting)}) {
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY,
"too many potential replacements", *err_string);
}
// Check if it's economically rational to mine this transaction rather