mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
Merge #10286: Call wallet notify callbacks in scheduler thread (without cs_main)
89f0312Remove redundant pwallet nullptr check (Matt Corallo)c4784b5Add a dev notes document describing the new wallet RPC blocking (Matt Corallo)3ea8b75Give ZMQ consistent order with UpdatedBlockTip on scheduler thread (Matt Corallo)cb06edfFix wallet RPC race by waiting for callbacks in sendrawtransaction (Matt Corallo)e545dedAlso call other wallet notify callbacks in scheduler thread (Matt Corallo)17220d6Use callbacks to cache whether wallet transactions are in mempool (Matt Corallo)5d67a78Add calls to CWallet::BlockUntilSyncedToCurrentChain() in RPCs (Matt Corallo)5ee3172Add CWallet::BlockUntilSyncedToCurrentChain() (Matt Corallo)0b2f42dAdd CallFunctionInQueue to wait on validation interface queue drain (Matt Corallo)2b4b345Add ability to assert a lock is not held in DEBUG_LOCKORDER (Matt Corallo)0343676Call TransactionRemovedFromMempool in the CScheduler thread (Matt Corallo)a7d3936Add a CValidationInterface::TransactionRemovedFromMempool (Matt Corallo) Pull request description: Based on #10179, this effectively reverts #9583, regaining most of the original speedups of #7946. This concludes the work of #9725, #10178, and #10179. See individual commit messages for more information. Tree-SHA512: eead4809b0a75d1fb33b0765174ff52c972e45040635e38cf3686cef310859c1e6b3c00e7186cbd17374c6ae547bfbd6c1718fe36f26c76ba8a8b052d6ed7bc9
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "init.h"
|
||||
#include "keystore.h"
|
||||
#include "validation.h"
|
||||
#include "validationinterface.h"
|
||||
#include "merkleblock.h"
|
||||
#include "net.h"
|
||||
#include "policy/policy.h"
|
||||
@@ -30,6 +31,7 @@
|
||||
#include "wallet/wallet.h"
|
||||
#endif
|
||||
|
||||
#include <future>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <univalue.h>
|
||||
@@ -917,7 +919,9 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
LOCK(cs_main);
|
||||
|
||||
std::promise<void> promise;
|
||||
|
||||
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL});
|
||||
|
||||
// parse hex string from parameter
|
||||
@@ -931,6 +935,8 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||
if (!request.params[1].isNull() && request.params[1].get_bool())
|
||||
nMaxRawTxFee = 0;
|
||||
|
||||
{ // cs_main scope
|
||||
LOCK(cs_main);
|
||||
CCoinsViewCache &view = *pcoinsTip;
|
||||
bool fHaveChain = false;
|
||||
for (size_t o = 0; !fHaveChain && o < tx->vout.size(); o++) {
|
||||
@@ -952,10 +958,24 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||
}
|
||||
throw JSONRPCError(RPC_TRANSACTION_ERROR, state.GetRejectReason());
|
||||
}
|
||||
} else {
|
||||
// If wallet is enabled, ensure that the wallet has been made aware
|
||||
// of the new transaction prior to returning. This prevents a race
|
||||
// where a user might call sendrawtransaction with a transaction
|
||||
// to/from their wallet, immediately call some wallet RPC, and get
|
||||
// a stale result because callbacks have not yet been processed.
|
||||
CallFunctionInValidationInterfaceQueue([&promise] {
|
||||
promise.set_value();
|
||||
});
|
||||
}
|
||||
} else if (fHaveChain) {
|
||||
throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain");
|
||||
}
|
||||
|
||||
} // cs_main
|
||||
|
||||
promise.get_future().wait();
|
||||
|
||||
if(!g_connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
|
||||
@@ -964,6 +984,7 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
pnode->PushInventory(inv);
|
||||
});
|
||||
|
||||
return hashTx.GetHex();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user