aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-04-17 15:14:05 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-04-17 15:14:12 -0400
commitdae72998e8576439254ee497e82e2b9ce4917977 (patch)
tree69a8b21b3f016e7d3eec75267e0db06cd2dd0f72 /src/wallet
parent429a7cf34fa880cfd5ad0cf80a9fa5a2b467a3c9 (diff)
parentfad7c33342cb51b310a7dd372bfa675df8810367 (diff)
downloadbitcoin-dae72998e8576439254ee497e82e2b9ce4917977.tar.xz
Merge #15779: test: Add wallet_balance benchmark
fad7c33342 refactor: Add handleNotifications method to wallet (MarcoFalke) fa46ac3127 bench: Add wallet_balance benchmarks (MarcoFalke) Pull request description: ACKs for commit fad7c3: ryanofsky: utACK fad7c33342cb51b310a7dd372bfa675df8810367. I might squash or rearrange the commits to avoid adding code in one commit that just gets deleted in the next one. But overall this looks good and the cleanup is nice. Tree-SHA512: 231faac168cbe9bb0ab4bf10ac1d5b042c610364406d75061fba27f1e9d16c71867e74cc4606e9f42659aa980d7133c00e29fcc18bbba7da2fa7a80178b3246c
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/test/wallet_test_fixture.cpp7
-rw-r--r--src/wallet/wallet.cpp13
-rw-r--r--src/wallet/wallet.h18
3 files changed, 24 insertions, 14 deletions
diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp
index 7b82994539..6526e69eea 100644
--- a/src/wallet/test/wallet_test_fixture.cpp
+++ b/src/wallet/test/wallet_test_fixture.cpp
@@ -8,12 +8,13 @@
#include <wallet/db.h>
#include <wallet/rpcwallet.h>
-WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
- TestingSetup(chainName), m_wallet(m_chain.get(), WalletLocation(), WalletDatabase::CreateMock())
+WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
+ : TestingSetup(chainName),
+ m_wallet(m_chain.get(), WalletLocation(), WalletDatabase::CreateMock())
{
bool fFirstRun;
m_wallet.LoadWallet(fFirstRun);
- m_wallet.m_chain_notifications_handler = m_chain->handleNotifications(m_wallet);
+ m_wallet.handleNotifications();
m_chain_client->registerRpcs();
}
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 98ba489729..4737e2f6f4 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -5,9 +5,8 @@
#include <wallet/wallet.h>
-#include <checkpoints.h>
#include <chain.h>
-#include <wallet/coincontrol.h>
+#include <checkpoints.h>
#include <consensus/consensus.h>
#include <consensus/validation.h>
#include <fs.h>
@@ -16,7 +15,6 @@
#include <key.h>
#include <key_io.h>
#include <keystore.h>
-#include <validation.h>
#include <net.h>
#include <policy/fees.h>
#include <policy/policy.h>
@@ -34,6 +32,8 @@
#include <util/moneystr.h>
#include <util/rbf.h>
#include <util/validation.h>
+#include <validation.h>
+#include <wallet/coincontrol.h>
#include <wallet/fees.h>
#include <algorithm>
@@ -4303,7 +4303,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
chain.loadWallet(interfaces::MakeWallet(walletInstance));
// Register with the validation interface. It's ok to do this after rescan since we're still holding locked_chain.
- walletInstance->m_chain_notifications_handler = chain.handleNotifications(*walletInstance);
+ walletInstance->handleNotifications();
walletInstance->SetBroadcastTransactions(gArgs.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
@@ -4316,6 +4316,11 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
return walletInstance;
}
+void CWallet::handleNotifications()
+{
+ m_chain_notifications_handler = m_chain->handleNotifications(*this);
+}
+
void CWallet::postInitProcess()
{
auto locked_chain = chain().lock();
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 53de1ea065..62ba0aa962 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -11,16 +11,16 @@
#include <interfaces/handler.h>
#include <outputtype.h>
#include <policy/feerate.h>
+#include <script/ismine.h>
+#include <script/sign.h>
#include <streams.h>
#include <tinyformat.h>
#include <ui_interface.h>
#include <util/strencodings.h>
-#include <validationinterface.h>
-#include <script/ismine.h>
-#include <script/sign.h>
#include <util/system.h>
-#include <wallet/crypter.h>
+#include <validationinterface.h>
#include <wallet/coinselection.h>
+#include <wallet/crypter.h>
#include <wallet/walletdb.h>
#include <wallet/walletutil.h>
@@ -767,7 +767,10 @@ public:
unsigned int nMasterKeyMaxID = 0;
/** Construct wallet with specified name and database implementation. */
- CWallet(interfaces::Chain* chain, const WalletLocation& location, std::unique_ptr<WalletDatabase> database) : m_chain(chain), m_location(location), database(std::move(database))
+ CWallet(interfaces::Chain* chain, const WalletLocation& location, std::unique_ptr<WalletDatabase> database)
+ : m_chain(chain),
+ m_location(location),
+ database(std::move(database))
{
}
@@ -794,6 +797,9 @@ public:
/** Registered interfaces::Chain::Notifications handler. */
std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
+ /** Register the wallet for chain notifications */
+ void handleNotifications();
+
/** Interface for accessing chain state. */
interfaces::Chain& chain() const { assert(m_chain); return *m_chain; }
@@ -1208,8 +1214,6 @@ public:
/** Add a KeyOriginInfo to the wallet */
bool AddKeyOrigin(const CPubKey& pubkey, const KeyOriginInfo& info);
-
- friend struct WalletTestingSetup;
};
/**