Skip to content

Commit 32748da

Browse files
committed
whitespace fixups after move and scripted-diff
1 parent fa47622 commit 32748da

File tree

3 files changed

+44
-62
lines changed

3 files changed

+44
-62
lines changed

src/policy/rbf.cpp

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@ std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
5757
uint64_t nConflictingCount = 0;
5858
for (const auto& mi : iters_conflicting) {
5959
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.
6362
if (nConflictingCount > MAX_BIP125_REPLACEMENT_CANDIDATES) {
6463
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);
6867
}
6968
}
7069
// If not too many to replace, then calculate the set of
@@ -82,28 +81,22 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx,
8281
AssertLockHeld(pool.cs);
8382
std::set<uint256> parents_of_conflicts;
8483
for (const auto& mi : iters_conflicting) {
85-
for (const CTxIn &txin : mi->GetTx().vin)
86-
{
84+
for (const CTxIn &txin : mi->GetTx().vin) {
8785
parents_of_conflicts.insert(txin.prevout.hash);
8886
}
8987
}
9088

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.
9793
//
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.
107100
if (pool.exists(tx.vin[j].prevout.hash)) {
108101
return strprintf("replacement %s adds unconfirmed input, idx %d",
109102
tx.GetHash().ToString(), j);
@@ -117,11 +110,9 @@ std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries&
117110
const std::set<uint256>& direct_conflicts,
118111
const uint256& txid)
119112
{
120-
for (CTxMemPool::txiter ancestorIt : ancestors)
121-
{
113+
for (CTxMemPool::txiter ancestorIt : ancestors) {
122114
const uint256 &hashAncestor = ancestorIt->GetTx().GetHash();
123-
if (direct_conflicts.count(hashAncestor))
124-
{
115+
if (direct_conflicts.count(hashAncestor)) {
125116
return strprintf("%s spends conflicting transaction %s",
126117
txid.ToString(),
127118
hashAncestor.ToString());
@@ -135,23 +126,18 @@ std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& i
135126
const uint256& txid)
136127
{
137128
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.
140130
//
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.
146134
//
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.
152139
CFeeRate original_feerate(mi->GetModifiedFee(), mi->GetTxSize());
153-
if (replacement_feerate <= original_feerate)
154-
{
140+
if (replacement_feerate <= original_feerate) {
155141
return strprintf("rejecting replacement %s; new feerate %s <= old feerate %s",
156142
txid.ToString(),
157143
replacement_feerate.ToString(),
@@ -169,17 +155,15 @@ std::optional<std::string> PaysForRBF(CAmount original_fees,
169155
// The replacement must pay greater fees than the transactions it
170156
// replaces - if we did the bandwidth used by those conflicting
171157
// transactions would not be paid for.
172-
if (replacement_fees < original_fees)
173-
{
158+
if (replacement_fees < original_fees) {
174159
return strprintf("rejecting replacement %s, less fees than conflicting txs; %s < %s",
175160
txid.ToString(), FormatMoney(replacement_fees), FormatMoney(original_fees));
176161
}
177162

178163
// Finally in addition to paying more fees than the conflicts the
179164
// new transaction must pay for its own bandwidth.
180165
CAmount additional_fees = replacement_fees - original_fees;
181-
if (additional_fees < ::incrementalRelayFee.GetFee(replacement_vsize))
182-
{
166+
if (additional_fees < ::incrementalRelayFee.GetFee(replacement_vsize)) {
183167
return strprintf("rejecting replacement %s, not enough additional fees to relay; %s < %s",
184168
txid.ToString(),
185169
FormatMoney(additional_fees),

src/policy/rbf.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx);
3939
* transactions to be replaced and their descendant transactions which will be evicted from the
4040
* mempool must not exceed a total of 100 transactions." Quit as early as possible. There cannot be
4141
* more than MAX_BIP125_REPLACEMENT_CANDIDATES potential entries.
42-
* @param[in] iters_conflicting The set of iterators to mempool entries.
43-
* @param[out] all_conflicts Populated with all the mempool entries that would be replaced,
42+
* @param[in] iters_conflicting The set of iterators to mempool entries.
43+
* @param[out] all_conflicts Populated with all the mempool entries that would be replaced,
4444
* which includes descendants of iters_conflicting. Not cleared at
4545
* the start; any existing mempool entries will remain in the set.
4646
* @returns an error message if Rule #5 is broken, otherwise a std::nullopt.
@@ -59,11 +59,11 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx, const CTx
5959

6060
/** Check the intersection between two sets of transactions (a set of mempool entries and a set of
6161
* txids) to make sure they are disjoint.
62-
* @param[in] ancestors Set of mempool entries corresponding to ancestors of the
63-
* replacement transactions.
62+
* @param[in] ancestors Set of mempool entries corresponding to ancestors of the
63+
* replacement transactions.
6464
* @param[in] direct_conflicts Set of txids corresponding to the mempool conflicts
65-
* (candidates to be replaced).
66-
* @param[in] txid Transaction ID, included in the error message if violation occurs.
65+
* (candidates to be replaced).
66+
* @param[in] txid Transaction ID, included in the error message if violation occurs.
6767
* @returns error message if the sets intersect, std::nullopt if they are disjoint.
6868
*/
6969
std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
@@ -81,9 +81,9 @@ std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& i
8181
/** Enforce BIP125 Rule #3 "The replacement transaction pays an absolute fee of at least the sum
8282
* paid by the original transactions." Enforce BIP125 Rule #4 "The replacement transaction must also
8383
* pay for its own bandwidth at or above the rate set by the node's minimum relay fee setting."
84-
* @param[in] original_fees Total modified fees of original transaction(s).
85-
* @param[in] replacement_fees Total modified fees of replacement transaction(s).
86-
* @param[in] replacement_vsize Total virtual size of replacement transaction(s).
84+
* @param[in] original_fees Total modified fees of original transaction(s).
85+
* @param[in] replacement_fees Total modified fees of replacement transaction(s).
86+
* @param[in] replacement_vsize Total virtual size of replacement transaction(s).
8787
* @param[in] txid Transaction ID, included in the error message if violation occurs.
8888
* @returns error string if fees are insufficient, otherwise std::nullopt.
8989
*/

src/util/rbf.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ class CTransaction;
1111

1212
static const uint32_t MAX_BIP125_RBF_SEQUENCE = 0xfffffffd;
1313

14-
/** Check whether the sequence numbers on this transaction are signaling
15-
* opt-in to replace-by-fee, according to BIP 125.
16-
* Allow opt-out of transaction replacement by setting
17-
* nSequence > MAX_BIP125_RBF_SEQUENCE (SEQUENCE_FINAL-2) on all inputs.
14+
/** Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,
15+
* according to BIP 125. Allow opt-out of transaction replacement by setting nSequence >
16+
* MAX_BIP125_RBF_SEQUENCE (SEQUENCE_FINAL-2) on all inputs.
1817
*
19-
* SEQUENCE_FINAL-1 is picked to still allow use of nLockTime by
20-
* non-replaceable transactions. All inputs rather than just one
21-
* is for the sake of multi-party protocols, where we don't
22-
* want a single party to be able to disable replacement. */
18+
* SEQUENCE_FINAL-1 is picked to still allow use of nLockTime by non-replaceable transactions. All
19+
* inputs rather than just one is for the sake of multi-party protocols, where we don't want a single
20+
* party to be able to disable replacement. */
2321
bool SignalsOptInRBF(const CTransaction &tx);
2422

2523
#endif // BITCOIN_UTIL_RBF_H

0 commit comments

Comments
 (0)