aboutsummaryrefslogtreecommitdiff
path: root/src/policy
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2021-09-02 15:27:37 +0100
committerglozow <gloriajzhao@gmail.com>2021-09-02 16:23:25 +0100
commitf8ad2a57c61d1e817e2445226688e03080fc8688 (patch)
tree2c10a7d397abd8aa7173c51f9064d02959cdc149 /src/policy
parentb3a2b8c29fda5d924726d3087535bd34af7012b6 (diff)
Make GetEntriesForConflicts return std::optional
Avoids reusing err_string.
Diffstat (limited to 'src/policy')
-rw-r--r--src/policy/rbf.cpp10
-rw-r--r--src/policy/rbf.h11
2 files changed, 9 insertions, 12 deletions
diff --git a/src/policy/rbf.cpp b/src/policy/rbf.cpp
index 43624c7993..3ff4c1f9c2 100644
--- a/src/policy/rbf.cpp
+++ b/src/policy/rbf.cpp
@@ -47,11 +47,10 @@ RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx)
return SignalsOptInRBF(tx) ? RBFTransactionState::REPLACEABLE_BIP125 : RBFTransactionState::UNKNOWN;
}
-bool GetEntriesForConflicts(const CTransaction& tx,
+std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
CTxMemPool& m_pool,
const CTxMemPool::setEntries& setIterConflicting,
- CTxMemPool::setEntries& allConflicting,
- std::string& err_string)
+ CTxMemPool::setEntries& allConflicting)
{
AssertLockHeld(m_pool.cs);
const uint256 hash = tx.GetHash();
@@ -62,11 +61,10 @@ bool GetEntriesForConflicts(const CTransaction& tx,
// but we just want to be conservative to avoid doing too much
// work.
if (nConflictingCount > MAX_BIP125_REPLACEMENT_CANDIDATES) {
- err_string = strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n",
+ return strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n",
hash.ToString(),
nConflictingCount,
MAX_BIP125_REPLACEMENT_CANDIDATES);
- return false;
}
}
// If not too many to replace, then calculate the set of
@@ -74,6 +72,6 @@ bool GetEntriesForConflicts(const CTransaction& tx,
for (CTxMemPool::txiter it : setIterConflicting) {
m_pool.CalculateDescendants(it, allConflicting);
}
- return true;
+ return std::nullopt;
}
diff --git a/src/policy/rbf.h b/src/policy/rbf.h
index a67e9058df..2a41ca8892 100644
--- a/src/policy/rbf.h
+++ b/src/policy/rbf.h
@@ -40,14 +40,13 @@ RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx);
* mempool must not exceed a total of 100 transactions." Quit as early as possible. There cannot be
* more than MAX_BIP125_REPLACEMENT_CANDIDATES potential entries.
* @param[in] setIterConflicting The set of iterators to mempool entries.
- * @param[out] err_string Used to return errors, if any.
* @param[out] allConflicting Populated with all the mempool entries that would be replaced,
* which includes descendants of setIterConflicting. Not cleared at
* the start; any existing mempool entries will remain in the set.
- * @returns false if Rule 5 is broken.
+ * @returns an error message if Rule #5 is broken, otherwise a std::nullopt.
*/
-bool GetEntriesForConflicts(const CTransaction& tx, CTxMemPool& m_pool,
- const CTxMemPool::setEntries& setIterConflicting,
- CTxMemPool::setEntries& allConflicting,
- std::string& err_string) EXCLUSIVE_LOCKS_REQUIRED(m_pool.cs);
+std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx, CTxMemPool& m_pool,
+ const CTxMemPool::setEntries& setIterConflicting,
+ CTxMemPool::setEntries& allConflicting)
+ EXCLUSIVE_LOCKS_REQUIRED(m_pool.cs);
#endif // BITCOIN_POLICY_RBF_H