mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01: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:
@@ -455,6 +455,11 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
CTxDestination dest = DecodeDestination(request.params[0].get_str());
|
||||
@@ -533,6 +538,11 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
UniValue jsonGroupings(UniValue::VARR);
|
||||
@@ -645,6 +655,11 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
// Bitcoin address
|
||||
@@ -707,6 +722,11 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
// Minimum confirmations
|
||||
@@ -780,6 +800,11 @@ UniValue getbalance(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
const UniValue& account_value = request.params[0];
|
||||
@@ -825,6 +850,11 @@ UniValue getunconfirmedbalance(const JSONRPCRequest &request)
|
||||
"Returns the server's total unconfirmed balance\n");
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
return ValueFromAmount(pwallet->GetUnconfirmedBalance());
|
||||
@@ -919,6 +949,11 @@ UniValue sendfrom(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
std::string strAccount = AccountFromValue(request.params[0]);
|
||||
@@ -1004,6 +1039,11 @@ UniValue sendmany(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
if (pwallet->GetBroadcastTransactions() && !g_connman) {
|
||||
@@ -1455,6 +1495,11 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
return ListReceived(pwallet, request.params, false);
|
||||
@@ -1495,6 +1540,11 @@ UniValue listreceivedbyaccount(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
return ListReceived(pwallet, request.params, true);
|
||||
@@ -1683,6 +1733,11 @@ UniValue listtransactions(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
std::string strAccount = "*";
|
||||
@@ -1777,6 +1832,11 @@ UniValue listaccounts(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
int nMinDepth = 1;
|
||||
@@ -1886,6 +1946,11 @@ UniValue listsinceblock(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
const CBlockIndex* pindex = nullptr; // Block index of the specified block or the common ancestor, if the block provided was in a deactivated chain.
|
||||
@@ -2019,6 +2084,11 @@ UniValue gettransaction(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
uint256 hash;
|
||||
@@ -2081,6 +2151,11 @@ UniValue abandontransaction(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
uint256 hash;
|
||||
@@ -2115,6 +2190,10 @@ UniValue backupwallet(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("backupwallet", "\"backup.dat\"")
|
||||
);
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
std::string strDest = request.params[0].get_str();
|
||||
@@ -2434,6 +2513,10 @@ UniValue lockunspent(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("lockunspent", "false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"")
|
||||
);
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
RPCTypeCheckArgument(request.params[0], UniValue::VBOOL);
|
||||
@@ -2593,6 +2676,11 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
@@ -2802,9 +2890,12 @@ UniValue listunspent(const JSONRPCRequest& request)
|
||||
nMaximumCount = options["maximumCount"].get_int64();
|
||||
}
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
UniValue results(UniValue::VARR);
|
||||
std::vector<COutput> vecOutputs;
|
||||
assert(pwallet != nullptr);
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
pwallet->AvailableCoins(vecOutputs, !include_unsafe, nullptr, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, nMinDepth, nMaxDepth);
|
||||
@@ -2912,6 +3003,10 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
||||
ObserveSafeMode();
|
||||
RPCTypeCheck(request.params, {UniValue::VSTR});
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
CCoinControl coinControl;
|
||||
int changePosition = -1;
|
||||
bool lockUnspents = false;
|
||||
@@ -3122,6 +3217,10 @@ UniValue bumpfee(const JSONRPCRequest& request)
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
EnsureWalletIsUnlocked(pwallet);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user