Bitcoin Core  22.99.0
P2P Digital Currency
context.h
Go to the documentation of this file.
1 // Copyright (c) 2020 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 class CWallet;
17 namespace interfaces {
18 class Chain;
19 class Wallet;
20 } // namespace interfaces
21 
22 using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
23 
34 struct WalletContext {
36  ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
37  // It is unsafe to lock this after locking a CWallet::cs_wallet mutex because
38  // this could introduce inconsistent lock ordering and cause deadlocks.
40  std::vector<std::shared_ptr<CWallet>> wallets GUARDED_BY(wallets_mutex);
41  std::list<LoadWalletFn> wallet_load_fns GUARDED_BY(wallets_mutex);
42 
46  WalletContext();
48 };
49 
50 #endif // BITCOIN_WALLET_CONTEXT_H
interfaces
Definition: dummywallet.cpp:11
sync.h
WalletContext::WalletContext
WalletContext()
Declare default constructor and destructor that are not inline, so code instantiating the WalletConte...
Definition: context.cpp:7
AnnotatedMixin< std::mutex >
wallet
Definition: interfaces.cpp:50
interfaces::Chain
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:92
WalletContext::wallets_mutex
Mutex wallets_mutex
Definition: context.h:39
ArgsManager
Definition: system.h:158
WalletContext::chain
interfaces::Chain * chain
Definition: context.h:35
CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:228
LoadWalletFn
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition: context.h:22
WalletContext::GUARDED_BY
std::vector< std::shared_ptr< CWallet > > wallets GUARDED_BY(wallets_mutex)
WalletContext::args
ArgsManager * args
Definition: context.h:36
WalletContext::~WalletContext
~WalletContext()
Definition: context.cpp:8
WalletContext
WalletContext struct containing references to state shared between CWallet instances,...
Definition: context.h:34