Merge bitcoin/bitcoin#33962: refactor: replace manual promise with SyncWithValidationInterfaceQueue

e71c4df1685131f5ab48aac6ccb07ac944e91e9f refactor: replace manual promise with SyncWithValidationInterfaceQueue (ANtutov)

Pull request description:

  `BroadcastTransaction()` now waits for validation callbacks using the built-in `validation_signals>SyncWithValidationInterfaceQueue()` instead of creating a local `std::promise` and scheduling a lambda. This removes an unnecessary allocation and uses the canonical API.

ACKs for top commit:
  maflcko:
    review ACK e71c4df1685131f5ab48aac6ccb07ac944e91e9f 🌃
  rkrux:
    lgtm ACK e71c4df1685131f5ab48aac6ccb07ac944e91e9f
  sedited:
    ACK e71c4df1685131f5ab48aac6ccb07ac944e91e9f

Tree-SHA512: 602994ba3c2ac91996068aee6eac7e788c3832d7ab949519a9420d2b59e2a67d2d4e67c3c9191ba60e9caa75f1524a95b0851fcd40b6732f6a9956a011b4a120
This commit is contained in:
merge-script 2026-01-27 18:00:05 +01:00
commit 9260b20ef1
No known key found for this signature in database
GPG Key ID: 9B79B45691DB4173

View File

@ -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;
@ -118,9 +115,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;
}
}
@ -129,7 +123,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) {