mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
[wallet] Remove locked_chain from CWallet, its RPCs and tests
This change is intended to make the bitcoin node and its rpc, network and gui interfaces more responsive while the wallet is in use. Currently because the node's cs_main mutex is always locked before the wallet's cs_wallet mutex (to prevent deadlocks), cs_main currently stays locked while the wallet does relatively slow things like creating and listing transactions. This commit only remmove chain lock tacking in wallet code, and invert lock order from cs_main, cs_wallet to cs_wallet, cs_main. must happen at once to avoid any deadlock. Previous commit were only removing Chain::Lock methods to Chain interface and enforcing they take cs_main. Remove LockChain method from CWallet and Chain::Lock interface.
This commit is contained in:
@@ -140,7 +140,6 @@ namespace feebumper {
|
||||
|
||||
bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid)
|
||||
{
|
||||
auto locked_chain = wallet.chain().lock();
|
||||
LOCK(wallet.cs_wallet);
|
||||
const CWalletTx* wtx = wallet.GetWalletTx(txid);
|
||||
if (wtx == nullptr) return false;
|
||||
@@ -156,7 +155,6 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
||||
// We are going to modify coin control later, copy to re-use
|
||||
CCoinControl new_coin_control(coin_control);
|
||||
|
||||
auto locked_chain = wallet.chain().lock();
|
||||
LOCK(wallet.cs_wallet);
|
||||
errors.clear();
|
||||
auto it = wallet.mapWallet.find(txid);
|
||||
@@ -240,14 +238,12 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
||||
}
|
||||
|
||||
bool SignTransaction(CWallet& wallet, CMutableTransaction& mtx) {
|
||||
auto locked_chain = wallet.chain().lock();
|
||||
LOCK(wallet.cs_wallet);
|
||||
return wallet.SignTransaction(mtx);
|
||||
}
|
||||
|
||||
Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<std::string>& errors, uint256& bumped_txid)
|
||||
{
|
||||
auto locked_chain = wallet.chain().lock();
|
||||
LOCK(wallet.cs_wallet);
|
||||
if (!errors.empty()) {
|
||||
return Result::MISC_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user