Skip to content

Commit cd1b140

Browse files
committed
node: Extend BroadcastTransaction to accept ignore_rejects
1 parent 9a7339f commit cd1b140

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/node/transaction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static TransactionError HandleATMPError(const TxValidationState& state, std::str
3131
}
3232
}
3333

34-
TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef tx, std::string& err_string, const std::variant<CAmount, CFeeRate>& max_tx_fee, bool relay, bool wait_callback)
34+
TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef tx, std::string& err_string, const std::variant<CAmount, CFeeRate>& max_tx_fee, bool relay, bool wait_callback, const ignore_rejects_type& ignore_rejects)
3535
{
3636
// BroadcastTransaction can be called by RPC or by the wallet.
3737
// chainman, mempool and peerman are initialized before the RPC server and wallet are started
@@ -73,7 +73,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
7373
if (max_tx_fee_set) {
7474
// First, call ATMP with test_accept and check the fee. If ATMP
7575
// fails here, return error immediately.
76-
const MempoolAcceptResult result = node.chainman->ProcessTransaction(tx, /*test_accept=*/ true);
76+
const MempoolAcceptResult result = node.chainman->ProcessTransaction(tx, /*test_accept=*/ true, ignore_rejects);
7777
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
7878
return HandleATMPError(result.m_state, err_string);
7979
} else {
@@ -89,7 +89,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
8989
}
9090
}
9191
// Try to submit the transaction to the mempool.
92-
const MempoolAcceptResult result = node.chainman->ProcessTransaction(tx, /*test_accept=*/ false);
92+
const MempoolAcceptResult result = node.chainman->ProcessTransaction(tx, /*test_accept=*/ false, ignore_rejects);
9393
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
9494
return HandleATMPError(result.m_state, err_string);
9595
}

src/node/transaction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <common/messages.h>
99
#include <policy/feerate.h>
1010
#include <primitives/transaction.h>
11+
#include <policy/policy.h>
1112

1213
#include <variant>
1314

@@ -51,7 +52,7 @@ static const CAmount DEFAULT_MAX_BURN_AMOUNT{0};
5152
* @param[in] wait_callback wait until callbacks have been processed to avoid stale result due to a sequentially RPC.
5253
* return error
5354
*/
54-
[[nodiscard]] TransactionError BroadcastTransaction(NodeContext& node, CTransactionRef tx, std::string& err_string, const std::variant<CAmount, CFeeRate>& max_tx_fee, bool relay, bool wait_callback);
55+
[[nodiscard]] TransactionError BroadcastTransaction(NodeContext& node, CTransactionRef tx, std::string& err_string, const std::variant<CAmount, CFeeRate>& max_tx_fee, bool relay, bool wait_callback, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
5556

5657
/**
5758
* Return transaction with a given hash.

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4626,7 +4626,7 @@ bool ChainstateManager::ProcessNewBlock(const std::shared_ptr<const CBlock>& blo
46264626
return true;
46274627
}
46284628

4629-
MempoolAcceptResult ChainstateManager::ProcessTransaction(const CTransactionRef& tx, bool test_accept)
4629+
MempoolAcceptResult ChainstateManager::ProcessTransaction(const CTransactionRef& tx, bool test_accept, const ignore_rejects_type& ignore_rejects)
46304630
{
46314631
AssertLockHeld(cs_main);
46324632
Chainstate& active_chainstate = ActiveChainstate();
@@ -4635,7 +4635,7 @@ MempoolAcceptResult ChainstateManager::ProcessTransaction(const CTransactionRef&
46354635
state.Invalid(TxValidationResult::TX_NO_MEMPOOL, "no-mempool");
46364636
return MempoolAcceptResult::Failure(state);
46374637
}
4638-
auto result = AcceptToMemoryPool(active_chainstate, tx, GetTime(), /*bypass_limits=*/ false, test_accept);
4638+
auto result = AcceptToMemoryPool(active_chainstate, tx, GetTime(), ignore_rejects, test_accept);
46394639
active_chainstate.GetMempool()->check(active_chainstate.CoinsTip(), active_chainstate.m_chain.Height() + 1);
46404640
return result;
46414641
}

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ class ChainstateManager
12611261
* @param[in] tx The transaction to submit for mempool acceptance.
12621262
* @param[in] test_accept When true, run validation checks but don't submit to mempool.
12631263
*/
1264-
[[nodiscard]] MempoolAcceptResult ProcessTransaction(const CTransactionRef& tx, bool test_accept=false)
1264+
[[nodiscard]] MempoolAcceptResult ProcessTransaction(const CTransactionRef& tx, bool test_accept=false, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects)
12651265
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
12661266

12671267
//! Load the block tree and coins database from disk, initializing state if we're running with -reindex

0 commit comments

Comments
 (0)