mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Add ChainClient setMockTime, getWallets methods
Needed to set mock times, and get wallet interface pointers correctly when wallet code is running in a different process from node code.
This commit is contained in:
@@ -280,6 +280,12 @@ public:
|
||||
|
||||
//! Shut down client.
|
||||
virtual void stop() = 0;
|
||||
|
||||
//! Set mock time.
|
||||
virtual void setMockTime(int64_t time) = 0;
|
||||
|
||||
//! Return interfaces for accessing wallets (if any).
|
||||
virtual std::vector<std::unique_ptr<Wallet>> getWallets() = 0;
|
||||
};
|
||||
|
||||
//! Return implementation of Chain interface.
|
||||
|
||||
@@ -251,8 +251,9 @@ public:
|
||||
std::vector<std::unique_ptr<Wallet>> getWallets() override
|
||||
{
|
||||
std::vector<std::unique_ptr<Wallet>> wallets;
|
||||
for (const std::shared_ptr<CWallet>& wallet : GetWallets()) {
|
||||
wallets.emplace_back(MakeWallet(wallet));
|
||||
for (auto& client : m_context.chain_clients) {
|
||||
auto client_wallets = client->getWallets();
|
||||
std::move(client_wallets.begin(), client_wallets.end(), std::back_inserter(wallets));
|
||||
}
|
||||
return wallets;
|
||||
}
|
||||
|
||||
@@ -529,6 +529,15 @@ public:
|
||||
void start(CScheduler& scheduler) override { return StartWallets(scheduler); }
|
||||
void flush() override { return FlushWallets(); }
|
||||
void stop() override { return StopWallets(); }
|
||||
void setMockTime(int64_t time) override { return SetMockTime(time); }
|
||||
std::vector<std::unique_ptr<Wallet>> getWallets() override
|
||||
{
|
||||
std::vector<std::unique_ptr<Wallet>> wallets;
|
||||
for (const auto& wallet : GetWallets()) {
|
||||
wallets.emplace_back(MakeWallet(wallet));
|
||||
}
|
||||
return wallets;
|
||||
}
|
||||
~WalletClientImpl() override { UnloadWallets(); }
|
||||
|
||||
Chain& m_chain;
|
||||
|
||||
Reference in New Issue
Block a user