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.
Switching the lock order so cs_main
is acquired after cs_wallet
allows cs_main
to be only locked intermittently while the wallet is doing slow operations, so the node is not blocked waiting for the wallet.
To review the present PR, most of getting right the move is ensuring any LockAssertion
in Chain::Lock
method is amended as a LOCK(cs_main)
. And in final commit, check that any wallet code which was previously locking the chain is now calling a method, enforcing the lock taking job. So far the only exception I found is handleNotifications
, which should be corrected.