refactor: replace manual promise with SyncWithValidationInterfaceQueue
This commit is contained in:
1 parent
808f1d972b
commit
e71c4df168
1 file changed
+1
-7
@@ -15,8 +15,6 @@
|
|||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
#include <node/transaction.h>
|
#include <node/transaction.h>
|
||||||
|
|
||||||
#include <future>
|
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
static TransactionError HandleATMPError(const TxValidationState& state, std::string& err_string_out)
|
static TransactionError HandleATMPError(const TxValidationState& state, std::string& err_string_out)
|
||||||
{
|
{
|
||||||
@@ -45,7 +43,6 @@ TransactionError BroadcastTransaction(NodeContext& node,
|
|||||||
assert(node.mempool);
|
assert(node.mempool);
|
||||||
assert(node.peerman);
|
assert(node.peerman);
|
||||||
|
|
||||||
std::promise<void> promise;
|
|
||||||
Txid txid = tx->GetHash();
|
Txid txid = tx->GetHash();
|
||||||
Wtxid wtxid = tx->GetWitnessHash();
|
Wtxid wtxid = tx->GetWitnessHash();
|
||||||
bool callback_set = false;
|
bool callback_set = false;
|
||||||
@@ -115,9 +112,6 @@ TransactionError BroadcastTransaction(NodeContext& node,
|
|||||||
// with a transaction to/from their wallet, immediately call some
|
// with a transaction to/from their wallet, immediately call some
|
||||||
// wallet RPC, and get a stale result because callbacks have not
|
// wallet RPC, and get a stale result because callbacks have not
|
||||||
// yet been processed.
|
// yet been processed.
|
||||||
node.validation_signals->CallFunctionInValidationInterfaceQueue([&promise] {
|
|
||||||
promise.set_value();
|
|
||||||
});
|
|
||||||
callback_set = true;
|
callback_set = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +120,7 @@ TransactionError BroadcastTransaction(NodeContext& node,
|
|||||||
if (callback_set) {
|
if (callback_set) {
|
||||||
// Wait until Validation Interface clients have been notified of the
|
// Wait until Validation Interface clients have been notified of the
|
||||||
// transaction entering the mempool.
|
// transaction entering the mempool.
|
||||||
promise.get_future().wait();
|
node.validation_signals->SyncWithValidationInterfaceQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (broadcast_method) {
|
switch (broadcast_method) {
|
||||||
|
|||||||
Reference in new issue
Block a user