Bitcoin Core  22.99.0
P2P Digital Currency
context.h
Go to the documentation of this file.
1 // Copyright (c) 2020-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_WALLET_CONTEXT_H
6 #define BITCOIN_WALLET_CONTEXT_H
7 
8 #include <sync.h>
9 
10 #include <functional>
11 #include <list>
12 #include <memory>
13 #include <vector>
14 
15 class ArgsManager;
16 namespace interfaces {
17 class Chain;
18 class Wallet;
19 } // namespace interfaces
20 
21 namespace wallet {
22 class CWallet;
23 using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
24 
35 struct WalletContext {
37  ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
38  // It is unsafe to lock this after locking a CWallet::cs_wallet mutex because
39  // this could introduce inconsistent lock ordering and cause deadlocks.
41  std::vector<std::shared_ptr<CWallet>> wallets GUARDED_BY(wallets_mutex);
42  std::list<LoadWalletFn> wallet_load_fns GUARDED_BY(wallets_mutex);
43 
47  WalletContext();
49 };
50 } // namespace wallet
51 
52 #endif // BITCOIN_WALLET_CONTEXT_H
interfaces
Definition: dummywallet.cpp:10
sync.h
AnnotatedMixin< std::mutex >
wallet::LoadWalletFn
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition: context.h:23
wallet
Definition: node.h:38
wallet::WalletContext::wallets_mutex
Mutex wallets_mutex
Definition: context.h:40
interfaces::Chain
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:94
wallet::WalletContext::args
ArgsManager * args
Definition: context.h:37
wallet::WalletContext::~WalletContext
~WalletContext()
Definition: context.cpp:9
wallet::WalletContext::WalletContext
WalletContext()
Declare default constructor and destructor that are not inline, so code instantiating the WalletConte...
Definition: context.cpp:8
wallet::WalletContext::GUARDED_BY
std::vector< std::shared_ptr< CWallet > > wallets GUARDED_BY(wallets_mutex)
ArgsManager
Definition: system.h:164
wallet::WalletContext
WalletContext struct containing references to state shared between CWallet instances,...
Definition: context.h:35
wallet::WalletContext::chain
interfaces::Chain * chain
Definition: context.h:36