refactor: replace manual promise with SyncWithValidationInterfaceQueue

This commit is contained in:
ANtutov 2025-12-10 11:48:50 +00:00
parent 808f1d972b
commit e71c4df168

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;
@ -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) {