wallet: Call load handlers without cs_wallet locked

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
This commit is contained in:
João Barbosa
2021-09-02 23:11:50 +01:00
parent 47fe7445e7
commit f13a22a631
3 changed files with 5 additions and 9 deletions

View File

@ -34,6 +34,8 @@ using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wall
struct WalletContext {
interfaces::Chain* chain{nullptr};
ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
// It is unsafe to lock this after locking a CWallet::cs_wallet mutex because
// this could introduce inconsistent lock ordering and cause deadlocks.
Mutex wallets_mutex;
std::vector<std::shared_ptr<CWallet>> wallets GUARDED_BY(wallets_mutex);
std::list<LoadWalletFn> wallet_load_fns GUARDED_BY(wallets_mutex);