aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/context.h
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2020-05-28 13:06:43 -0400
committerRussell Yanofsky <russ@yanofsky.org>2021-08-17 04:05:15 -0400
commit62a09a30772141ef4add2f10d29927211abf57eb (patch)
tree7158ee4508efa9696316741cafcddad9a507b7cd /src/wallet/context.h
parentfdd80b0a53b4af0b29cb6e03118e2456d053a757 (diff)
downloadbitcoin-62a09a30772141ef4add2f10d29927211abf57eb.tar.xz
refactor: remove ::vpwallets and related global variables
Move global wallet variables to WalletContext struct
Diffstat (limited to 'src/wallet/context.h')
-rw-r--r--src/wallet/context.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/wallet/context.h b/src/wallet/context.h
index a83591154f..a382fb9021 100644
--- a/src/wallet/context.h
+++ b/src/wallet/context.h
@@ -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