mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-12 16:52:41 +02:00
refactor: remove ::vpwallets and related global variables
Move global wallet variables to WalletContext struct
This commit is contained in:
@ -5,11 +5,22 @@
|
||||
#ifndef BITCOIN_WALLET_CONTEXT_H
|
||||
#define BITCOIN_WALLET_CONTEXT_H
|
||||
|
||||
#include <sync.h>
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class ArgsManager;
|
||||
class CWallet;
|
||||
namespace interfaces {
|
||||
class Chain;
|
||||
class Wallet;
|
||||
} // namespace interfaces
|
||||
|
||||
using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
|
||||
|
||||
//! WalletContext struct containing references to state shared between CWallet
|
||||
//! instances, like the reference to the chain interface, and the list of opened
|
||||
//! wallets.
|
||||
@ -22,7 +33,10 @@ class Chain;
|
||||
//! behavior.
|
||||
struct WalletContext {
|
||||
interfaces::Chain* chain{nullptr};
|
||||
ArgsManager* args{nullptr};
|
||||
ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
||||
Mutex wallets_mutex;
|
||||
std::vector<std::shared_ptr<CWallet>> wallets GUARDED_BY(wallets_mutex);
|
||||
std::list<LoadWalletFn> wallet_load_fns GUARDED_BY(wallets_mutex);
|
||||
|
||||
//! Declare default constructor and destructor that are not inline, so code
|
||||
//! instantiating the WalletContext struct doesn't need to #include class
|
||||
|
Reference in New Issue
Block a user