refactor: replace manual promise with SyncWithValidationInterfaceQueue
What changed, and why it matters
This is a small internal cleanup in Bitcoin Core's transaction-broadcasting code. It replaces a hand-rolled 'promise/future' wait mechanism with an existing helper function that does the same job. There is no security bug being fixed here; the change just makes the code simpler and easier to maintain.
No security action required. Treat as a normal code-quality refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors BroadcastTransaction() in src/node/transaction.cpp. Previously the code created a std::promise
Changed components
src/node/transaction.cppBroadcastTransaction()Inspect captured patch +1 / −7
diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp
index f5bd0efe..05450299 100644
--- a/src/node/transaction.cpp
+++ b/src/node/transaction.cpp
@@ -15,8 +15,6 @@
#include <validationinterface.h>
#include <node/transaction.h>
-#include <future>
-
namespace node {
static TransactionError HandleATMPError(const TxValidationState& state, std::string& err_string_out)
{
@@ -45,7 +43,6 @@ TransactionError BroadcastTransaction(NodeContext& node,
assert(node.mempool);
assert(node.peerman);
- std::promise<void> promise;
Txid txid = tx->GetHash();
Wtxid wtxid = tx->GetWitnessHash();
bool callback_set = false;
@@ -115,9 +112,6 @@ TransactionError BroadcastTransaction(NodeContext& node,
// with a transaction to/from their wallet, immediately call some
// wallet RPC, and get a stale result because callbacks have not
// yet been processed.
- node.validation_signals->CallFunctionInValidationInterfaceQueue([&promise] {
- promise.set_value();
- });
callback_set = true;
}
}
@@ -126,7 +120,7 @@ TransactionError BroadcastTransaction(NodeContext& node,
if (callback_set) {
// Wait until Validation Interface clients have been notified of the
// transaction entering the mempool.
- promise.get_future().wait();
+ node.validation_signals->SyncWithValidationInterfaceQueue();
}
switch (broadcast_method) {
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.