@@ -57,14 +57,13 @@ std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
57
57
uint64_t nConflictingCount = 0 ;
58
58
for (const auto & mi : iters_conflicting) {
59
59
nConflictingCount += mi->GetCountWithDescendants ();
60
- // This potentially overestimates the number of actual descendants
61
- // but we just want to be conservative to avoid doing too much
62
- // work.
60
+ // This potentially overestimates the number of actual descendants but we just want to be
61
+ // conservative to avoid doing too much work.
63
62
if (nConflictingCount > MAX_BIP125_REPLACEMENT_CANDIDATES) {
64
63
return strprintf (" rejecting replacement %s; too many potential replacements (%d > %d)\n " ,
65
- txid.ToString (),
66
- nConflictingCount,
67
- MAX_BIP125_REPLACEMENT_CANDIDATES);
64
+ txid.ToString (),
65
+ nConflictingCount,
66
+ MAX_BIP125_REPLACEMENT_CANDIDATES);
68
67
}
69
68
}
70
69
// If not too many to replace, then calculate the set of
@@ -82,28 +81,22 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx,
82
81
AssertLockHeld (pool.cs );
83
82
std::set<uint256> parents_of_conflicts;
84
83
for (const auto & mi : iters_conflicting) {
85
- for (const CTxIn &txin : mi->GetTx ().vin )
86
- {
84
+ for (const CTxIn &txin : mi->GetTx ().vin ) {
87
85
parents_of_conflicts.insert (txin.prevout .hash );
88
86
}
89
87
}
90
88
91
- for (unsigned int j = 0 ; j < tx.vin .size (); j++)
92
- {
93
- // We don't want to accept replacements that require low
94
- // feerate junk to be mined first. Ideally we'd keep track of
95
- // the ancestor feerates and make the decision based on that,
96
- // but for now requiring all new inputs to be confirmed works.
89
+ for (unsigned int j = 0 ; j < tx.vin .size (); j++) {
90
+ // We don't want to accept replacements that require low feerate junk to be mined first.
91
+ // Ideally we'd keep track of the ancestor feerates and make the decision based on that, but
92
+ // for now requiring all new inputs to be confirmed works.
97
93
//
98
- // Note that if you relax this to make RBF a little more useful,
99
- // this may break the CalculateMempoolAncestors RBF relaxation,
100
- // above. See the comment above the first CalculateMempoolAncestors
101
- // call for more info.
102
- if (!parents_of_conflicts.count (tx.vin [j].prevout .hash ))
103
- {
104
- // Rather than check the UTXO set - potentially expensive -
105
- // it's cheaper to just check if the new input refers to a
106
- // tx that's in the mempool.
94
+ // Note that if you relax this to make RBF a little more useful, this may break the
95
+ // CalculateMempoolAncestors RBF relaxation, above. See the comment above the first
96
+ // CalculateMempoolAncestors call for more info.
97
+ if (!parents_of_conflicts.count (tx.vin [j].prevout .hash )) {
98
+ // Rather than check the UTXO set - potentially expensive - it's cheaper to just check
99
+ // if the new input refers to a tx that's in the mempool.
107
100
if (pool.exists (tx.vin [j].prevout .hash )) {
108
101
return strprintf (" replacement %s adds unconfirmed input, idx %d" ,
109
102
tx.GetHash ().ToString (), j);
@@ -117,11 +110,9 @@ std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries&
117
110
const std::set<uint256>& direct_conflicts,
118
111
const uint256& txid)
119
112
{
120
- for (CTxMemPool::txiter ancestorIt : ancestors)
121
- {
113
+ for (CTxMemPool::txiter ancestorIt : ancestors) {
122
114
const uint256 &hashAncestor = ancestorIt->GetTx ().GetHash ();
123
- if (direct_conflicts.count (hashAncestor))
124
- {
115
+ if (direct_conflicts.count (hashAncestor)) {
125
116
return strprintf (" %s spends conflicting transaction %s" ,
126
117
txid.ToString (),
127
118
hashAncestor.ToString ());
@@ -135,23 +126,18 @@ std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& i
135
126
const uint256& txid)
136
127
{
137
128
for (const auto & mi : iters_conflicting) {
138
- // Don't allow the replacement to reduce the feerate of the
139
- // mempool.
129
+ // Don't allow the replacement to reduce the feerate of the mempool.
140
130
//
141
- // We usually don't want to accept replacements with lower
142
- // feerates than what they replaced as that would lower the
143
- // feerate of the next block. Requiring that the feerate always
144
- // be increased is also an easy-to-reason about way to prevent
145
- // DoS attacks via replacements.
131
+ // We usually don't want to accept replacements with lower feerates than what they replaced
132
+ // as that would lower the feerate of the next block. Requiring that the feerate always be
133
+ // increased is also an easy-to-reason about way to prevent DoS attacks via replacements.
146
134
//
147
- // We only consider the feerates of transactions being directly
148
- // replaced, not their indirect descendants. While that does
149
- // mean high feerate children are ignored when deciding whether
150
- // or not to replace, we do require the replacement to pay more
151
- // overall fees too, mitigating most cases.
135
+ // We only consider the feerates of transactions being directly replaced, not their indirect
136
+ // descendants. While that does mean high feerate children are ignored when deciding whether
137
+ // or not to replace, we do require the replacement to pay more overall fees too, mitigating
138
+ // most cases.
152
139
CFeeRate original_feerate (mi->GetModifiedFee (), mi->GetTxSize ());
153
- if (replacement_feerate <= original_feerate)
154
- {
140
+ if (replacement_feerate <= original_feerate) {
155
141
return strprintf (" rejecting replacement %s; new feerate %s <= old feerate %s" ,
156
142
txid.ToString (),
157
143
replacement_feerate.ToString (),
@@ -169,17 +155,15 @@ std::optional<std::string> PaysForRBF(CAmount original_fees,
169
155
// The replacement must pay greater fees than the transactions it
170
156
// replaces - if we did the bandwidth used by those conflicting
171
157
// transactions would not be paid for.
172
- if (replacement_fees < original_fees)
173
- {
158
+ if (replacement_fees < original_fees) {
174
159
return strprintf (" rejecting replacement %s, less fees than conflicting txs; %s < %s" ,
175
160
txid.ToString (), FormatMoney (replacement_fees), FormatMoney (original_fees));
176
161
}
177
162
178
163
// Finally in addition to paying more fees than the conflicts the
179
164
// new transaction must pay for its own bandwidth.
180
165
CAmount additional_fees = replacement_fees - original_fees;
181
- if (additional_fees < ::incrementalRelayFee.GetFee (replacement_vsize))
182
- {
166
+ if (additional_fees < ::incrementalRelayFee.GetFee (replacement_vsize)) {
183
167
return strprintf (" rejecting replacement %s, not enough additional fees to relay; %s < %s" ,
184
168
txid.ToString (),
185
169
FormatMoney (additional_fees),
0 commit comments