Bitcoin Core 28.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
15class ArgsManager;
16class CScheduler;
17namespace interfaces {
18class Chain;
19class Wallet;
20} // namespace interfaces
21
22namespace wallet {
23class CWallet;
24using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
25
39 ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
40 // It is unsafe to lock this after locking a CWallet::cs_wallet mutex because
41 // this could introduce inconsistent lock ordering and cause deadlocks.
43 std::vector<std::shared_ptr<CWallet>> wallets GUARDED_BY(wallets_mutex);
44 std::list<LoadWalletFn> wallet_load_fns GUARDED_BY(wallets_mutex);
45
51};
52} // namespace wallet
53
54#endif // BITCOIN_WALLET_CONTEXT_H
Simple class for background tasks that should be run periodically or once "after a while".
Definition: scheduler.h:40
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Definition: chain.h:129
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
Definition: context.h:24
WalletContext struct containing references to state shared between CWallet instances,...
Definition: context.h:36
interfaces::Chain * chain
Definition: context.h:37
std::vector< std::shared_ptr< CWallet > > wallets GUARDED_BY(wallets_mutex)
WalletContext()
Declare default constructor and destructor that are not inline, so code instantiating the WalletConte...
CScheduler * scheduler
Definition: context.h:38
ArgsManager * args
Definition: context.h:39
std::list< LoadWalletFn > wallet_load_fns GUARDED_BY(wallets_mutex)