aboutsummaryrefslogtreecommitdiff
path: root/src/policy/rbf.cpp
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2021-07-27 14:23:40 +0100
committerglozow <gloriajzhao@gmail.com>2021-08-24 15:51:54 +0100
commitf293c68be0469894c988711559f5528020c0ff71 (patch)
tree4bcd1740db9364d2801ce5268d84b10819233d9b /src/policy/rbf.cpp
parent8d7179633552f58ca0d23305196dcb4249b6dce7 (diff)
downloadbitcoin-f293c68be0469894c988711559f5528020c0ff71.tar.xz
MOVEONLY: getting mempool conflicts to policy/rbf
Diffstat (limited to 'src/policy/rbf.cpp')
-rw-r--r--src/policy/rbf.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/policy/rbf.cpp b/src/policy/rbf.cpp
index 8125b41c41..43624c7993 100644
--- a/src/policy/rbf.cpp
+++ b/src/policy/rbf.cpp
@@ -3,6 +3,10 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <policy/rbf.h>
+
+#include <policy/settings.h>
+#include <tinyformat.h>
+#include <util/moneystr.h>
#include <util/rbf.h>
RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool)
@@ -42,3 +46,34 @@ RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx)
// If we don't have a local mempool we can only check the transaction itself.
return SignalsOptInRBF(tx) ? RBFTransactionState::REPLACEABLE_BIP125 : RBFTransactionState::UNKNOWN;
}
+
+bool GetEntriesForConflicts(const CTransaction& tx,
+ CTxMemPool& m_pool,
+ const CTxMemPool::setEntries& setIterConflicting,
+ CTxMemPool::setEntries& allConflicting,
+ std::string& err_string)
+{
+ AssertLockHeld(m_pool.cs);
+ const uint256 hash = tx.GetHash();
+ uint64_t nConflictingCount = 0;
+ for (const auto& mi : setIterConflicting) {
+ nConflictingCount += mi->GetCountWithDescendants();
+ // This potentially overestimates the number of actual descendants
+ // 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",
+ hash.ToString(),
+ nConflictingCount,
+ MAX_BIP125_REPLACEMENT_CANDIDATES);
+ return false;
+ }
+ }
+ // If not too many to replace, then calculate the set of
+ // transactions that would have to be evicted
+ for (CTxMemPool::txiter it : setIterConflicting) {
+ m_pool.CalculateDescendants(it, allConflicting);
+ }
+ return true;
+}
+