Skip to content

Commit fa83168

Browse files
MarcoFalkejnewbery
andcommitted
refactor: Add IsRBFOptInEmptyMempool
Co-authored-by: John Newbery <[email protected]>
1 parent df75e9f commit fa83168

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/interfaces/chain.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ class ChainImpl : public Chain
276276
}
277277
RBFTransactionState isRBFOptIn(const CTransaction& tx) override
278278
{
279-
LOCK(::mempool.cs);
280-
return IsRBFOptIn(tx, ::mempool);
279+
if (!m_node.mempool) return IsRBFOptInEmptyMempool(tx);
280+
LOCK(m_node.mempool->cs);
281+
return IsRBFOptIn(tx, *m_node.mempool);
281282
}
282283
bool hasDescendantsInMempool(const uint256& txid) override
283284
{

src/policy/rbf.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool)
3636
}
3737
return RBFTransactionState::FINAL;
3838
}
39+
40+
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx)
41+
{
42+
// If we don't have a local mempool we can only check the transaction itself.
43+
return SignalsOptInRBF(tx) ? RBFTransactionState::REPLACEABLE_BIP125 : RBFTransactionState::UNKNOWN;
44+
}

src/policy/rbf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ enum class RBFTransactionState {
1818
// This involves checking sequence numbers of the transaction, as well
1919
// as the sequence numbers of all in-mempool ancestors.
2020
RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
21+
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx);
2122

2223
#endif // BITCOIN_POLICY_RBF_H

0 commit comments

Comments
 (0)