aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.h
diff options
context:
space:
mode:
authorGreg Sanders <gsanders87@gmail.com>2024-01-19 15:20:33 -0500
committerGreg Sanders <gsanders87@gmail.com>2024-03-18 10:32:00 -0400
commit2079b80854e2595f6f696e7c13a56c7f2a7da9f4 (patch)
treeab42fae71ea1aa30bccdc9598aa02284a3f93d98 /src/txmempool.h
parent66d966dcfaad3638f84654e710f403cb0a0a2ac7 (diff)
downloadbitcoin-2079b80854e2595f6f696e7c13a56c7f2a7da9f4.tar.xz
Implement ImprovesFeerateDiagram
This new function takes the populated sets of direct and all conflicts computed in the current mempool, assuming the replacements are a single chunk, and computes a diagram check. The diagram check only works against cluster sizes of 2 or less, and fails if it encounters a different topology. Co-authored-by: Suhas Daftuar <sdaftuar@chaincode.com>
Diffstat (limited to 'src/txmempool.h')
-rw-r--r--src/txmempool.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/txmempool.h b/src/txmempool.h
index 32f2c024f7..9dd4d56da7 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -21,6 +21,7 @@
#include <util/epochguard.h>
#include <util/hasher.h>
#include <util/result.h>
+#include <util/feefrac.h>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/identity.hpp>
@@ -736,6 +737,28 @@ public:
return m_sequence_number;
}
+ /**
+ * Calculate the old and new mempool feerate diagrams relating to the
+ * clusters that would be affected by a potential replacement transaction.
+ * (replacement_fees, replacement_vsize) values are gathered from a
+ * proposed set of replacement transactions that are considered as a single
+ * chunk, and represent their complete cluster. In other words, they have no
+ * in-mempool ancestors.
+ *
+ * @param[in] replacement_fees Package fees
+ * @param[in] replacement_vsize Package size (must be greater than 0)
+ * @param[in] direct_conflicts All transactions that would be removed directly by
+ * having a conflicting input with a proposed transaction
+ * @param[in] all_conflicts All transactions that would be removed
+ * @return old and new diagram pair respectively, or an error string if the conflicts don't match a calculable topology
+ */
+ util::Result<std::pair<std::vector<FeeFrac>, std::vector<FeeFrac>>> CalculateFeerateDiagramsForRBF(CAmount replacement_fees, int64_t replacement_vsize, const setEntries& direct_conflicts, const setEntries& all_conflicts) EXCLUSIVE_LOCKS_REQUIRED(cs);
+
+ /* Check that all direct conflicts are in a cluster size of two or less. Each
+ * direct conflict may be in a separate cluster.
+ */
+ std::optional<std::string> CheckConflictTopology(const setEntries& direct_conflicts);
+
private:
/** UpdateForDescendants is used by UpdateTransactionsFromBlock to update
* the descendants for a single transaction that has been added to the