File tree Expand file tree Collapse file tree 4 files changed +26
-3
lines changed Expand file tree Collapse file tree 4 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,12 @@ class ChainClient
280
280
281
281
// ! Shut down client.
282
282
virtual void stop () = 0;
283
+
284
+ // ! Set mock time.
285
+ virtual void setMockTime (int64_t time) = 0;
286
+
287
+ // ! Return interfaces for accessing wallets (if any).
288
+ virtual std::vector<std::unique_ptr<Wallet>> getWallets () = 0;
283
289
};
284
290
285
291
// ! Return implementation of Chain interface.
Original file line number Diff line number Diff line change @@ -251,8 +251,9 @@ class NodeImpl : public Node
251
251
std::vector<std::unique_ptr<Wallet>> getWallets () override
252
252
{
253
253
std::vector<std::unique_ptr<Wallet>> wallets;
254
- for (const std::shared_ptr<CWallet>& wallet : GetWallets ()) {
255
- wallets.emplace_back (MakeWallet (wallet));
254
+ for (auto & client : m_context.chain_clients ) {
255
+ auto client_wallets = client->getWallets ();
256
+ std::move (client_wallets.begin (), client_wallets.end (), std::back_inserter (wallets));
256
257
}
257
258
return wallets;
258
259
}
Original file line number Diff line number Diff line change @@ -529,6 +529,15 @@ class WalletClientImpl : public ChainClient
529
529
void start (CScheduler& scheduler) override { return StartWallets (scheduler); }
530
530
void flush () override { return FlushWallets (); }
531
531
void stop () override { return StopWallets (); }
532
+ void setMockTime (int64_t time) override { return SetMockTime (time); }
533
+ std::vector<std::unique_ptr<Wallet>> getWallets () override
534
+ {
535
+ std::vector<std::unique_ptr<Wallet>> wallets;
536
+ for (const auto & wallet : GetWallets ()) {
537
+ wallets.emplace_back (MakeWallet (wallet));
538
+ }
539
+ return wallets;
540
+ }
532
541
~WalletClientImpl () override { UnloadWallets (); }
533
542
534
543
Chain& m_chain;
Original file line number Diff line number Diff line change 4
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
6
6
#include < httpserver.h>
7
+ #include < interfaces/chain.h>
7
8
#include < key_io.h>
8
9
#include < node/context.h>
9
10
#include < outputtype.h>
@@ -356,7 +357,13 @@ static UniValue setmocktime(const JSONRPCRequest& request)
356
357
LOCK (cs_main);
357
358
358
359
RPCTypeCheck (request.params , {UniValue::VNUM});
359
- SetMockTime (request.params [0 ].get_int64 ());
360
+ int64_t time = request.params [0 ].get_int64 ();
361
+ SetMockTime (time);
362
+ if (g_rpc_node) {
363
+ for (const auto & chain_client : g_rpc_node->chain_clients ) {
364
+ chain_client->setMockTime (time);
365
+ }
366
+ }
360
367
361
368
return NullUniValue;
362
369
}
You can’t perform that action at this time.
0 commit comments